Algorithmic Trading Model for Exponential Moving Average Crossover Grid Search

Task 1. Prepare Environment

In [1]:
import os
import sys
import numpy as np
import pandas as pd
import requests
import json
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
In [2]:
stock_symbol = 'GOOGL'
initial_capital = 0

# Specify the parameters for the trading strategy
fast_ma_min = 5
fast_ma_max = 20
slow_ma_min = 10
slow_ma_max = 50
ma_increment = 5
min_ma_gap = 5

model_start_date = datetime(2019, 1, 1)
print("Starting date for the model:", model_start_date)
stock_start_date = model_start_date - timedelta(days=int(slow_ma_max*1.5)) # Need more pricing data to calculate moving averages

model_end_date = datetime.now()
# model_end_date = datetime(2020, 6, 30)
print("Ending date for the model:", model_end_date)
Starting date for the model: 2019-01-01 00:00:00
Ending date for the model: 2020-07-01 22:45:47.954098
In [3]:
# Begin the timer for the script processing
startTimeScript = datetime.now()

# Set up the verbose flag to print detailed messages for debugging (setting True will activate!)
verbose = True

# Set up the sendNotification flag to send progress emails (setting True will send emails!)
notifyStatus = False

# Set up the parent directory location for loading the dotenv files
useColab = False
if useColab:
    # Mount Google Drive locally for storing files
    from dotenv import load_dotenv
    from google.colab import drive
    drive.mount('/content/gdrive')
    gdrivePrefix = '/content/gdrive/My Drive/Colab_Downloads/'
    env_path = '/content/gdrive/My Drive/Colab Notebooks/'
    dotenv_path = env_path + "python_script.env"
    load_dotenv(dotenv_path=dotenv_path)

# Set up the dotenv file for retrieving environment variables
useLocalPC = False
if useLocalPC:
    from dotenv import load_dotenv
    env_path = "/Users/david/PycharmProjects/"
    dotenv_path = env_path + "python_script.env"
    load_dotenv(dotenv_path=dotenv_path)

# Configure the plotting style
plt.style.use('seaborn')

# Set Pandas options
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
# pd.set_option("display.width", 140)

Task 2. Acquire and Pre-Process Data

In [4]:
# Check and see whether the API key is available
quandl_key = os.environ.get('QUANDL_API')
if quandl_key is None: sys.exit("API key for Quandl not available. Script Processing Aborted!!!")
In [5]:
start_date_string = stock_start_date.strftime('%Y-%m-%d')
end_date_string = model_end_date.strftime('%Y-%m-%d')

quandl_url = "https://www.quandl.com/api/v3/datatables/SHARADAR/SEP.json?date.gte=%s&date.lte=%s&ticker=%s&api_key=%s" % (start_date_string, end_date_string, stock_symbol, quandl_key)
In [6]:
response = requests.get(quandl_url)
quandl_dict = json.loads(response.text)
stock_quandl = pd.DataFrame(quandl_dict['datatable']['data'])
print(len(stock_quandl), 'data points retrieved from the API call.')
428 data points retrieved from the API call.
In [7]:
stock_quandl.columns = ['ticker', 'date', 'open', 'high', 'low', 'close', 'volume', 'dividend', 'closeunadj', 'lastupdated']
# stock_quandl.set_index('date', inplace=True)
stock_quandl.index = pd.to_datetime(stock_quandl.date)
stock_quandl = stock_quandl.sort_index(ascending = True)
stock_quandl.info(verbose=True)
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 428 entries, 2018-10-18 to 2020-07-01
Data columns (total 10 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   ticker       428 non-null    object 
 1   date         428 non-null    object 
 2   open         428 non-null    float64
 3   high         428 non-null    float64
 4   low          428 non-null    float64
 5   close        428 non-null    float64
 6   volume       428 non-null    float64
 7   dividend     428 non-null    float64
 8   closeunadj   428 non-null    float64
 9   lastupdated  428 non-null    object 
dtypes: float64(7), object(3)
memory usage: 36.8+ KB
In [8]:
stock_quandl.head()
Out[8]:
ticker date open high low close volume dividend closeunadj lastupdated
date
2018-10-18 GOOGL 2018-10-18 1130.00 1132.35 1086.34 1097.91 2307596.0 0.0 1097.91 2020-05-01
2018-10-19 GOOGL 2018-10-19 1103.71 1120.95 1097.03 1105.18 2064289.0 0.0 1105.18 2020-05-01
2018-10-22 GOOGL 2018-10-22 1112.51 1121.69 1100.00 1111.37 1355842.0 0.0 1111.37 2020-05-01
2018-10-23 GOOGL 2018-10-23 1091.29 1118.00 1079.01 1114.91 1884255.0 0.0 1114.91 2020-05-01
2018-10-24 GOOGL 2018-10-24 1115.00 1116.62 1055.06 1057.12 2464295.0 0.0 1057.12 2020-05-01
In [9]:
stock_quandl.tail()
Out[9]:
ticker date open high low close volume dividend closeunadj lastupdated
date
2020-06-25 GOOGL 2020-06-25 1431.22 1442.32 1419.54 1441.10 1194083.0 0.0 1441.10 2020-06-25
2020-06-26 GOOGL 2020-06-26 1432.63 1437.02 1355.00 1362.54 4882014.0 0.0 1362.54 2020-06-26
2020-06-29 GOOGL 2020-06-29 1360.34 1398.00 1351.65 1397.17 2246904.0 0.0 1397.17 2020-06-30
2020-06-30 GOOGL 2020-06-30 1396.88 1424.00 1386.93 1418.05 2007224.0 0.0 1418.05 2020-06-30
2020-07-01 GOOGL 2020-07-01 1419.17 1448.48 1414.18 1442.00 2071186.0 0.0 1442.00 2020-07-01
In [10]:
title_string = 'Quandl Historical Stock Information for ' + stock_symbol
stock_quandl['close'].plot(figsize=(16,9), title=title_string)
plt.show()

Task 3. Develop Strategy and Train Model

3.a) Set up the Dataframe for the Trading Model

In [11]:
# Set up the standard column name for modeling
model_template = stock_quandl.loc[:, ['open','close']]
model_template.rename(columns={'open': 'open_price', 'close': 'close_price'}, inplace=True)
if verbose: model_template.info(verbose=True)
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 428 entries, 2018-10-18 to 2020-07-01
Data columns (total 2 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   open_price   428 non-null    float64
 1   close_price  428 non-null    float64
dtypes: float64(2)
memory usage: 10.0 KB

3.b) Set up the Analysis Table with Indicators

In [12]:
def trading_ma_crossover(model):
    waitfor_first_entry = True
    for x in range(len(model)):
        if model['ma_change'].iloc[x] > 0:
            model['trade_signal'].iloc[x] = 1  # trade_signal = 1 means we should take a long position
        else:
            model['trade_signal'].iloc[x] = 0  # trade_signal = 0 means we should take a flat position
        if x != 0:
            model['signal_change'].iloc[x] = model['trade_signal'].iloc[x] - model['trade_signal'].iloc[x-1]
            if waitfor_first_entry and (model['signal_change'].iloc[x-1] == 1):
                model['entry_exit'].iloc[x] = model['signal_change'].iloc[x-1]
                waitfor_first_entry = False
            elif (not waitfor_first_entry) and (model['signal_change'].iloc[x-1] != 0):
                model['entry_exit'].iloc[x] = model['signal_change'].iloc[x-1]
In [13]:
model_collection = {}
serial_number = 1

for slow_ma in range(slow_ma_min, slow_ma_max+1, ma_increment):
    for fast_ma in range(fast_ma_min, fast_ma_max+1, ma_increment):
        if (slow_ma - fast_ma) < min_ma_gap: break
        print('Processing model with slow_ma of', slow_ma, 'and fast_ma of', fast_ma)
        model_name = 'EMA_' + str(serial_number).zfill(3) + '_SlowMA_' + str(slow_ma).zfill(2) + '_FastMA_' + str(fast_ma).zfill(2)
        serial_number = serial_number + 1
        trading_model = model_template.copy()
        trading_model['fast_ma'] = trading_model['close_price'].ewm(span=fast_ma).mean()
        trading_model['slow_ma'] = trading_model['close_price'].ewm(span=slow_ma).mean()
        trading_model['ma_change'] = trading_model['fast_ma'] - trading_model['slow_ma']
        trading_model['trade_signal'] = np.zeros(len(trading_model))
        trading_model['signal_change'] = np.zeros(len(trading_model))
        trading_model['entry_exit'] = np.zeros(len(trading_model))
        trading_model = trading_model[model_start_date:model_end_date]
        trading_ma_crossover(trading_model)
        model_collection[model_name] = trading_model.copy()
        print('Model', model_name, 'added to the trading model collection.')
Processing model with slow_ma of 10 and fast_ma of 5
Model EMA_001_SlowMA_10_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 15 and fast_ma of 5
Model EMA_002_SlowMA_15_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 15 and fast_ma of 10
Model EMA_003_SlowMA_15_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 20 and fast_ma of 5
Model EMA_004_SlowMA_20_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 20 and fast_ma of 10
Model EMA_005_SlowMA_20_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 20 and fast_ma of 15
Model EMA_006_SlowMA_20_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 25 and fast_ma of 5
Model EMA_007_SlowMA_25_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 25 and fast_ma of 10
Model EMA_008_SlowMA_25_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 25 and fast_ma of 15
Model EMA_009_SlowMA_25_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 25 and fast_ma of 20
Model EMA_010_SlowMA_25_FastMA_20 added to the trading model collection.
Processing model with slow_ma of 30 and fast_ma of 5
Model EMA_011_SlowMA_30_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 30 and fast_ma of 10
Model EMA_012_SlowMA_30_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 30 and fast_ma of 15
Model EMA_013_SlowMA_30_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 30 and fast_ma of 20
Model EMA_014_SlowMA_30_FastMA_20 added to the trading model collection.
Processing model with slow_ma of 35 and fast_ma of 5
Model EMA_015_SlowMA_35_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 35 and fast_ma of 10
Model EMA_016_SlowMA_35_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 35 and fast_ma of 15
Model EMA_017_SlowMA_35_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 35 and fast_ma of 20
Model EMA_018_SlowMA_35_FastMA_20 added to the trading model collection.
Processing model with slow_ma of 40 and fast_ma of 5
Model EMA_019_SlowMA_40_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 40 and fast_ma of 10
Model EMA_020_SlowMA_40_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 40 and fast_ma of 15
Model EMA_021_SlowMA_40_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 40 and fast_ma of 20
Model EMA_022_SlowMA_40_FastMA_20 added to the trading model collection.
Processing model with slow_ma of 45 and fast_ma of 5
Model EMA_023_SlowMA_45_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 45 and fast_ma of 10
Model EMA_024_SlowMA_45_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 45 and fast_ma of 15
Model EMA_025_SlowMA_45_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 45 and fast_ma of 20
Model EMA_026_SlowMA_45_FastMA_20 added to the trading model collection.
Processing model with slow_ma of 50 and fast_ma of 5
Model EMA_027_SlowMA_50_FastMA_05 added to the trading model collection.
Processing model with slow_ma of 50 and fast_ma of 10
Model EMA_028_SlowMA_50_FastMA_10 added to the trading model collection.
Processing model with slow_ma of 50 and fast_ma of 15
Model EMA_029_SlowMA_50_FastMA_15 added to the trading model collection.
Processing model with slow_ma of 50 and fast_ma of 20
Model EMA_030_SlowMA_50_FastMA_20 added to the trading model collection.
In [14]:
# List the entry/exit points for each model
for key in model_collection:
    print('List the signal change and entry/exit points for', key)
    if verbose: print(model_collection[key][(model_collection[key].signal_change != 0) | (model_collection[key].entry_exit != 0)])
    else: print(model_collection[key][model_collection[key].entry_exit != 0])
    print()
List the signal change and entry/exit points for EMA_001_SlowMA_10_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-03     1050.67      1025.47  1038.328799  1038.606313  -0.277514   
2019-01-04     1042.56      1078.07  1051.575866  1045.781701   5.794165   
2019-01-07     1080.97      1075.92  1059.690577  1051.261500   8.429078   
2019-01-29     1081.04      1070.06  1081.554609  1081.978623  -0.424014   
2019-01-30     1077.36      1097.99  1087.033073  1084.889785   2.143288   
2019-01-31     1112.24      1125.89  1099.985382  1092.344374   7.641007   
2019-02-21     1118.78      1104.21  1116.425545  1117.222473  -0.796928   
2019-02-22     1109.70      1116.56  1116.470364  1117.102024  -0.631660   
2019-02-26     1114.37      1122.01  1118.507939  1118.028297   0.479643   
2019-02-27     1114.01      1122.89  1119.968626  1118.912243   1.056383   
2019-03-27     1191.92      1178.01  1193.660472  1194.226927  -0.566455   
2019-03-28     1175.50      1172.27  1186.530315  1190.234758  -3.704443   
2019-04-02     1200.05      1205.54  1194.205279  1192.694244   1.511034   
2019-04-03     1212.70      1210.81  1199.740186  1195.988018   3.752168   
2019-05-01     1197.50      1173.32  1224.228908  1234.907030 -10.678122   
2019-05-02     1172.60      1166.51  1204.989272  1222.471207 -17.481934   
2019-06-17     1089.10      1093.89  1086.373968  1085.986037   0.387930   
2019-06-18     1111.50      1105.24  1092.662645  1089.486758   3.175887   
2019-06-26     1091.00      1080.32  1096.082701  1097.355593  -1.272891   
2019-06-27     1086.75      1076.63  1089.598468  1093.587303  -3.988836   
2019-07-02     1104.83      1112.60  1098.569916  1096.685157   1.884759   
2019-07-03     1118.50      1122.99  1106.709944  1101.467856   5.242088   
2019-08-06     1165.52      1171.08  1183.114404  1184.135127  -1.020723   
2019-08-07     1157.80      1175.91  1180.712936  1182.639649  -1.926713   
2019-08-08     1186.43      1206.19  1189.205291  1186.921531   2.283760   
2019-08-09     1199.99      1188.90  1189.103527  1187.281253   1.822274   
2019-08-12     1180.00      1174.50  1184.235685  1184.957389  -0.721704   
2019-08-13     1174.35      1196.73  1188.400456  1187.097863   1.302593   
2019-08-14     1176.07      1164.25  1180.350304  1182.943706  -2.593402   
2019-08-15     1168.43      1169.32  1176.673536  1180.466669  -3.793133   
2019-08-19     1191.83      1200.44  1185.159349  1183.911241   1.248108   
2019-08-20     1195.35      1183.53  1184.616233  1183.841925   0.774308   
2019-08-23     1185.17      1153.58  1176.836662  1180.423774  -3.587112   
2019-08-26     1159.45      1171.18  1174.951108  1178.743088  -3.791980   
2019-08-29     1186.42      1194.24  1180.501810  1179.853592   0.648218   
2019-08-30     1200.35      1190.53  1183.844540  1181.794757   2.049783   
2019-09-03     1181.85      1169.55  1179.079693  1179.568438  -0.488744   
2019-09-04     1179.45      1182.27  1180.143129  1180.059631   0.083498   
2019-09-05     1193.66      1212.19  1190.825419  1185.901516   4.923903   
2019-10-01     1222.49      1206.00  1221.416013  1224.636539  -3.220525   
2019-10-02     1196.50      1177.92  1206.917342  1216.142622  -9.225280   
2019-10-14     1213.89      1217.77  1211.151131  1210.073139   1.077992   
2019-10-15     1221.50      1242.24  1221.514087  1215.921659   5.592428   
2019-11-22     1303.00      1293.67  1302.310599  1302.364315  -0.053716   
2019-11-25     1296.26      1305.64  1303.420399  1302.959894   0.460505   
2019-11-26     1309.91      1313.00  1306.613600  1304.785368   1.828232   
2019-12-02     1302.56      1288.86  1300.952178  1302.680341  -1.728163   
2019-12-03     1278.66      1294.74  1298.881452  1301.236642  -2.355191   
2019-12-04     1306.10      1318.94  1305.567635  1304.455435   1.112200   
2019-12-05     1327.00      1326.96  1312.698423  1308.547174   4.151249   
2019-12-31     1335.79      1339.39  1345.964531  1347.015668  -1.051137   
2020-01-02     1348.41      1368.68  1353.536354  1350.954637   2.581716   
2020-01-03     1348.00      1361.52  1356.197569  1352.875612   3.321957   
2020-01-31     1467.86      1432.78  1447.860323  1449.207622  -1.347299   
2020-02-03     1461.65      1482.60  1459.440215  1455.278964   4.161252   
2020-02-04     1454.49      1445.41  1454.763477  1453.484607   1.278870   
2020-02-05     1463.61      1446.05  1451.858985  1452.132860  -0.273875   
2020-02-06     1451.98      1475.97  1459.895990  1456.466885   3.429104   
2020-02-07     1467.38      1479.11  1466.300660  1460.583815   5.716845   
2020-02-24     1423.05      1419.86  1477.063444  1487.234636 -10.171192   
2020-02-25     1431.00      1386.32  1446.815629  1468.886520 -22.070891   
2020-03-31     1148.73      1161.95  1139.081204  1138.296537   0.784667   
2020-04-01     1124.00      1102.10  1126.754136  1131.715349  -4.961212   
2020-04-02     1100.00      1117.03  1123.512758  1129.045285  -5.532528   
2020-04-06     1133.00      1183.19  1136.557892  1133.483042   3.074850   
2020-04-07     1217.01      1182.56  1151.891928  1142.406125   9.485803   
2020-06-12     1425.86      1412.92  1426.764783  1428.261595  -1.496811   
2020-06-15     1389.49      1420.74  1424.756522  1426.894032  -2.137510   
2020-06-16     1449.00      1446.47  1431.994348  1430.453299   1.541049   
2020-06-17     1452.94      1452.54  1438.842899  1434.469063   4.373836   
2020-06-26     1432.63      1362.54  1415.499219  1425.745870 -10.246651   
2020-06-29     1360.34      1397.17  1409.389479  1420.550257 -11.160778   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-03           0.0           -1.0         0.0  
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-01-29           0.0           -1.0         0.0  
2019-01-30           1.0            1.0        -1.0  
2019-01-31           1.0            0.0         1.0  
2019-02-21           0.0           -1.0         0.0  
2019-02-22           0.0            0.0        -1.0  
2019-02-26           1.0            1.0         0.0  
2019-02-27           1.0            0.0         1.0  
2019-03-27           0.0           -1.0         0.0  
2019-03-28           0.0            0.0        -1.0  
2019-04-02           1.0            1.0         0.0  
2019-04-03           1.0            0.0         1.0  
2019-05-01           0.0           -1.0         0.0  
2019-05-02           0.0            0.0        -1.0  
2019-06-17           1.0            1.0         0.0  
2019-06-18           1.0            0.0         1.0  
2019-06-26           0.0           -1.0         0.0  
2019-06-27           0.0            0.0        -1.0  
2019-07-02           1.0            1.0         0.0  
2019-07-03           1.0            0.0         1.0  
2019-08-06           0.0           -1.0         0.0  
2019-08-07           0.0            0.0        -1.0  
2019-08-08           1.0            1.0         0.0  
2019-08-09           1.0            0.0         1.0  
2019-08-12           0.0           -1.0         0.0  
2019-08-13           1.0            1.0        -1.0  
2019-08-14           0.0           -1.0         1.0  
2019-08-15           0.0            0.0        -1.0  
2019-08-19           1.0            1.0         0.0  
2019-08-20           1.0            0.0         1.0  
2019-08-23           0.0           -1.0         0.0  
2019-08-26           0.0            0.0        -1.0  
2019-08-29           1.0            1.0         0.0  
2019-08-30           1.0            0.0         1.0  
2019-09-03           0.0           -1.0         0.0  
2019-09-04           1.0            1.0        -1.0  
2019-09-05           1.0            0.0         1.0  
2019-10-01           0.0           -1.0         0.0  
2019-10-02           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2019-11-22           0.0           -1.0         0.0  
2019-11-25           1.0            1.0        -1.0  
2019-11-26           1.0            0.0         1.0  
2019-12-02           0.0           -1.0         0.0  
2019-12-03           0.0            0.0        -1.0  
2019-12-04           1.0            1.0         0.0  
2019-12-05           1.0            0.0         1.0  
2019-12-31           0.0           -1.0         0.0  
2020-01-02           1.0            1.0        -1.0  
2020-01-03           1.0            0.0         1.0  
2020-01-31           0.0           -1.0         0.0  
2020-02-03           1.0            1.0        -1.0  
2020-02-04           1.0            0.0         1.0  
2020-02-05           0.0           -1.0         0.0  
2020-02-06           1.0            1.0        -1.0  
2020-02-07           1.0            0.0         1.0  
2020-02-24           0.0           -1.0         0.0  
2020-02-25           0.0            0.0        -1.0  
2020-03-31           1.0            1.0         0.0  
2020-04-01           0.0           -1.0         1.0  
2020-04-02           0.0            0.0        -1.0  
2020-04-06           1.0            1.0         0.0  
2020-04-07           1.0            0.0         1.0  
2020-06-12           0.0           -1.0         0.0  
2020-06-15           0.0            0.0        -1.0  
2020-06-16           1.0            1.0         0.0  
2020-06-17           1.0            0.0         1.0  
2020-06-26           0.0           -1.0         0.0  
2020-06-29           0.0            0.0        -1.0  

List the signal change and entry/exit points for EMA_002_SlowMA_15_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-03     1050.67      1025.47  1038.328799  1040.994140  -2.665341   
2019-01-04     1042.56      1078.07  1051.575866  1045.632538   5.943328   
2019-01-07     1080.97      1075.92  1059.690577  1049.421269  10.269308   
2019-03-29     1180.18      1176.89  1183.316877  1185.166532  -1.849656   
2019-04-01     1187.54      1198.98  1188.537918  1186.893216   1.644702   
2019-04-02     1200.05      1205.54  1194.205279  1189.224065   4.981214   
2019-05-01     1197.50      1173.32  1224.228908  1233.530859  -9.301950   
2019-05-02     1172.60      1166.51  1204.989272  1225.153251 -20.163979   
2019-06-19     1107.24      1104.51  1096.611763  1095.571105   1.040658   
2019-06-20     1121.70      1113.20  1102.141176  1097.774717   4.366459   
2019-06-26     1091.00      1080.32  1096.082701  1098.599874  -2.517173   
2019-06-27     1086.75      1076.63  1089.598468  1095.853640  -6.255172   
2019-07-02     1104.83      1112.60  1098.569916  1097.151169   1.418747   
2019-07-03     1118.50      1122.99  1106.709944  1100.381023   6.328921   
2019-08-14     1176.07      1164.25  1180.350304  1180.656270  -0.305965   
2019-08-15     1168.43      1169.32  1176.673536  1179.239236  -2.565700   
2019-08-19     1191.83      1200.44  1185.159349  1181.886134   3.273216   
2019-08-20     1195.35      1183.53  1184.616233  1182.091617   2.524616   
2019-08-23     1185.17      1153.58  1176.836662  1180.466962  -3.630301   
2019-08-26     1159.45      1171.18  1174.951108  1179.306092  -4.354984   
2019-08-29     1186.42      1194.24  1180.501810  1179.752987   0.748822   
2019-08-30     1200.35      1190.53  1183.844540  1181.100114   2.744426   
2019-09-03     1181.85      1169.55  1179.079693  1179.656350  -0.576657   
2019-09-04     1179.45      1182.27  1180.143129  1179.983056   0.160073   
2019-09-05     1193.66      1212.19  1190.825419  1184.008924   6.816495   
2019-10-01     1222.49      1206.00  1221.416013  1222.797146  -1.381132   
2019-10-02     1196.50      1177.92  1206.917342  1217.187503 -10.270160   
2019-10-14     1213.89      1217.77  1211.151131  1210.854331   0.296799   
2019-10-15     1221.50      1242.24  1221.514087  1214.777540   6.736547   
2019-12-03     1278.66      1294.74  1298.881452  1299.845754  -0.964302   
2019-12-04     1306.10      1318.94  1305.567635  1302.232534   3.335100   
2019-12-05     1327.00      1326.96  1312.698423  1305.323468   7.374955   
2020-02-24     1423.05      1419.86  1477.063444  1484.957371  -7.893927   
2020-02-25     1431.00      1386.32  1446.815629  1472.627700 -25.812070   
2020-04-07     1217.01      1182.56  1151.891928  1149.218975   2.672953   
2020-04-08     1203.10      1207.00  1170.261285  1156.441603  13.819683   
2020-06-26     1432.63      1362.54  1415.499219  1426.702084 -11.202866   
2020-06-29     1360.34      1397.17  1409.389479  1423.010574 -13.621095   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-03           0.0           -1.0         0.0  
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-03-29           0.0           -1.0         0.0  
2019-04-01           1.0            1.0        -1.0  
2019-04-02           1.0            0.0         1.0  
2019-05-01           0.0           -1.0         0.0  
2019-05-02           0.0            0.0        -1.0  
2019-06-19           1.0            1.0         0.0  
2019-06-20           1.0            0.0         1.0  
2019-06-26           0.0           -1.0         0.0  
2019-06-27           0.0            0.0        -1.0  
2019-07-02           1.0            1.0         0.0  
2019-07-03           1.0            0.0         1.0  
2019-08-14           0.0           -1.0         0.0  
2019-08-15           0.0            0.0        -1.0  
2019-08-19           1.0            1.0         0.0  
2019-08-20           1.0            0.0         1.0  
2019-08-23           0.0           -1.0         0.0  
2019-08-26           0.0            0.0        -1.0  
2019-08-29           1.0            1.0         0.0  
2019-08-30           1.0            0.0         1.0  
2019-09-03           0.0           -1.0         0.0  
2019-09-04           1.0            1.0        -1.0  
2019-09-05           1.0            0.0         1.0  
2019-10-01           0.0           -1.0         0.0  
2019-10-02           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2019-12-03           0.0           -1.0         0.0  
2019-12-04           1.0            1.0        -1.0  
2019-12-05           1.0            0.0         1.0  
2020-02-24           0.0           -1.0         0.0  
2020-02-25           0.0            0.0        -1.0  
2020-04-07           1.0            1.0         0.0  
2020-04-08           1.0            0.0         1.0  
2020-06-26           0.0           -1.0         0.0  
2020-06-29           0.0            0.0        -1.0  

List the signal change and entry/exit points for EMA_003_SlowMA_15_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1045.781701  1045.632538   0.149163   
2019-01-07     1080.97      1075.92  1051.261500  1049.421269   1.840230   
2019-05-02     1172.60      1166.51  1222.471207  1225.153251  -2.682045   
2019-05-03     1177.41      1189.55  1216.485533  1220.702845  -4.217312   
2019-06-21     1109.86      1125.37  1101.367097  1101.224127   0.142970   
2019-06-24     1120.00      1116.70  1104.154898  1103.158611   0.996286   
2019-06-25     1115.08      1087.58  1101.141280  1101.211285  -0.070005   
2019-06-26     1091.00      1080.32  1097.355593  1098.599874  -1.244282   
2019-07-03     1118.50      1122.99  1101.467856  1100.381023   1.086833   
2019-07-05     1119.37      1132.66  1107.139155  1104.415895   2.723260   
2019-08-23     1185.17      1153.58  1180.423774  1180.466962  -0.043188   
2019-08-26     1159.45      1171.18  1178.743088  1179.306092  -0.563004   
2019-08-29     1186.42      1194.24  1179.853592  1179.752987   0.100605   
2019-08-30     1200.35      1190.53  1181.794757  1181.100114   0.694643   
2019-09-03     1181.85      1169.55  1179.568438  1179.656350  -0.087912   
2019-09-04     1179.45      1182.27  1180.059631  1179.983056   0.076575   
2019-09-05     1193.66      1212.19  1185.901516  1184.008924   1.892592   
2019-10-02     1196.50      1177.92  1216.142622  1217.187503  -1.044880   
2019-10-03     1183.34      1189.43  1211.285782  1213.717815  -2.432033   
2019-10-15     1221.50      1242.24  1215.921659  1214.777540   1.144119   
2019-10-16     1241.81      1243.00  1220.844994  1218.305348   2.539646   
2020-02-25     1431.00      1386.32  1468.886520  1472.627700  -3.741179   
2020-02-26     1394.98      1390.47  1454.628971  1462.357987  -7.729016   
2020-04-09     1218.18      1206.57  1163.681291  1162.707653   0.973638   
2020-04-13     1201.50      1210.41  1172.177420  1168.670446   3.506974   
2020-06-26     1432.63      1362.54  1425.745870  1426.702084  -0.956214   
2020-06-29     1360.34      1397.17  1420.550257  1423.010574  -2.460316   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-05-02           0.0           -1.0         0.0  
2019-05-03           0.0            0.0        -1.0  
2019-06-21           1.0            1.0         0.0  
2019-06-24           1.0            0.0         1.0  
2019-06-25           0.0           -1.0         0.0  
2019-06-26           0.0            0.0        -1.0  
2019-07-03           1.0            1.0         0.0  
2019-07-05           1.0            0.0         1.0  
2019-08-23           0.0           -1.0         0.0  
2019-08-26           0.0            0.0        -1.0  
2019-08-29           1.0            1.0         0.0  
2019-08-30           1.0            0.0         1.0  
2019-09-03           0.0           -1.0         0.0  
2019-09-04           1.0            1.0        -1.0  
2019-09-05           1.0            0.0         1.0  
2019-10-02           0.0           -1.0         0.0  
2019-10-03           0.0            0.0        -1.0  
2019-10-15           1.0            1.0         0.0  
2019-10-16           1.0            0.0         1.0  
2020-02-25           0.0           -1.0         0.0  
2020-02-26           0.0            0.0        -1.0  
2020-04-09           1.0            1.0         0.0  
2020-04-13           1.0            0.0         1.0  
2020-06-26           0.0           -1.0         0.0  
2020-06-29           0.0            0.0        -1.0  

List the signal change and entry/exit points for EMA_004_SlowMA_20_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1051.575866  1046.976263   4.599603   
2019-01-07     1080.97      1075.92  1059.690577  1049.745260   9.945318   
2019-05-01     1197.50      1173.32  1224.228908  1229.390969  -5.162060   
2019-05-02     1172.60      1166.51  1204.989272  1223.402296 -18.413024   
2019-06-21     1109.86      1125.37  1109.884117  1105.224579   4.659538   
2019-06-24     1120.00      1116.70  1112.156078  1106.317476   5.838602   
2019-06-25     1115.08      1087.58  1103.964052  1104.532955  -0.568903   
2019-06-26     1091.00      1080.32  1096.082701  1102.226959  -6.144258   
2019-07-03     1118.50      1122.99  1106.709944  1101.920723   4.789221   
2019-07-05     1119.37      1132.66  1115.359963  1104.848274  10.511689   
2019-08-23     1185.17      1153.58  1176.836662  1178.531484  -1.694822   
2019-08-26     1159.45      1171.18  1174.951108  1177.831342  -2.880235   
2019-08-29     1186.42      1194.24  1180.501810  1178.495778   2.006032   
2019-08-30     1200.35      1190.53  1183.844540  1179.641894   4.202646   
2019-10-02     1196.50      1177.92  1206.917342  1215.534752  -8.617410   
2019-10-03     1183.34      1189.43  1201.088228  1213.048585 -11.960357   
2019-10-14     1213.89      1217.77  1211.151131  1210.848648   0.302483   
2019-10-15     1221.50      1242.24  1221.514087  1213.838301   7.675787   
2020-02-24     1423.05      1419.86  1477.063444  1479.200477  -2.137033   
2020-02-25     1431.00      1386.32  1446.815629  1470.354717 -23.539088   
2020-04-08     1203.10      1207.00  1170.261285  1168.202703   2.058582   
2020-04-09     1218.18      1206.57  1182.364190  1171.856732  10.507459   
2020-06-26     1432.63      1362.54  1415.499219  1423.512090  -8.012871   
2020-06-29     1360.34      1397.17  1409.389479  1421.003319 -11.613840   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-05-01           0.0           -1.0         0.0  
2019-05-02           0.0            0.0        -1.0  
2019-06-21           1.0            1.0         0.0  
2019-06-24           1.0            0.0         1.0  
2019-06-25           0.0           -1.0         0.0  
2019-06-26           0.0            0.0        -1.0  
2019-07-03           1.0            1.0         0.0  
2019-07-05           1.0            0.0         1.0  
2019-08-23           0.0           -1.0         0.0  
2019-08-26           0.0            0.0        -1.0  
2019-08-29           1.0            1.0         0.0  
2019-08-30           1.0            0.0         1.0  
2019-10-02           0.0           -1.0         0.0  
2019-10-03           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2020-02-24           0.0           -1.0         0.0  
2020-02-25           0.0            0.0        -1.0  
2020-04-08           1.0            1.0         0.0  
2020-04-09           1.0            0.0         1.0  
2020-06-26           0.0           -1.0         0.0  
2020-06-29           0.0            0.0        -1.0  

List the signal change and entry/exit points for EMA_005_SlowMA_20_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-07     1080.97      1075.92  1051.261500  1049.745260   1.516240   
2019-01-08     1086.00      1085.37  1057.463145  1053.151951   4.311194   
2019-05-02     1172.60      1166.51  1222.471207  1223.402296  -0.931089   
2019-05-03     1177.41      1189.55  1216.485533  1220.178263  -3.692731   
2019-07-05     1119.37      1132.66  1107.139155  1104.848274   2.290881   
2019-07-08     1125.87      1116.79  1108.893854  1105.985581   2.908273   
2019-08-28     1164.87      1173.75  1176.656612  1176.838491  -0.181879   
2019-08-29     1186.42      1194.24  1179.853592  1178.495778   1.357814   
2019-08-30     1200.35      1190.53  1181.794757  1179.641894   2.152863   
2019-10-03     1183.34      1189.43  1211.285782  1213.048585  -1.762803   
2019-10-04     1194.29      1210.96  1211.226549  1212.849672  -1.623123   
2019-10-15     1221.50      1242.24  1215.921659  1213.838301   2.083358   
2019-10-16     1241.81      1243.00  1220.844994  1216.615605   4.229388   
2020-02-25     1431.00      1386.32  1468.886520  1470.354717  -1.468197   
2020-02-26     1394.98      1390.47  1454.628971  1462.746649  -8.117678   
2020-04-14     1239.97      1265.23  1189.096071  1184.071474   5.024596   
2020-04-15     1246.51      1257.30  1201.496785  1191.045619  10.451166   
2020-06-29     1360.34      1397.17  1420.550257  1421.003319  -0.453062   
2020-06-30     1396.88      1418.05  1420.095665  1420.722051  -0.626386   
2020-07-01     1419.17      1442.00  1424.078271  1422.748522   1.329749   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-07           1.0            1.0         0.0  
2019-01-08           1.0            0.0         1.0  
2019-05-02           0.0           -1.0         0.0  
2019-05-03           0.0            0.0        -1.0  
2019-07-05           1.0            1.0         0.0  
2019-07-08           1.0            0.0         1.0  
2019-08-28           0.0           -1.0         0.0  
2019-08-29           1.0            1.0        -1.0  
2019-08-30           1.0            0.0         1.0  
2019-10-03           0.0           -1.0         0.0  
2019-10-04           0.0            0.0        -1.0  
2019-10-15           1.0            1.0         0.0  
2019-10-16           1.0            0.0         1.0  
2020-02-25           0.0           -1.0         0.0  
2020-02-26           0.0            0.0        -1.0  
2020-04-14           1.0            1.0         0.0  
2020-04-15           1.0            0.0         1.0  
2020-06-29           0.0           -1.0         0.0  
2020-06-30           0.0            0.0        -1.0  
2020-07-01           1.0            1.0         0.0  

List the signal change and entry/exit points for EMA_006_SlowMA_20_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1053.917767  1053.151951   0.765816   
2019-01-09     1087.99      1081.65  1057.386257  1055.876077   1.510180   
2019-05-06     1172.00      1193.46  1217.297489  1217.633664  -0.336175   
2019-05-07     1185.81      1178.86  1212.492803  1213.940930  -1.448127   
2019-07-09     1110.32      1124.29  1108.253576  1107.728859   0.524717   
2019-07-10     1132.32      1140.91  1112.335629  1110.888968   1.446661   
2019-10-08     1198.77      1190.13  1209.907364  1210.289550  -0.382186   
2019-10-09     1201.33      1202.40  1208.968944  1209.538165  -0.569221   
2019-10-14     1213.89      1217.77  1210.854331  1210.848648   0.005683   
2019-10-15     1221.50      1242.24  1214.777540  1213.838301   0.939239   
2020-02-26     1394.98      1390.47  1462.357987  1462.746649  -0.388662   
2020-02-27     1359.14      1314.95  1443.931989  1448.670777  -4.738789   
2020-04-16     1267.14      1257.43  1198.700299  1197.367941   1.332357   
2020-04-17     1281.70      1279.00  1208.737761  1205.142423   3.595338   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-06           0.0           -1.0         0.0  
2019-05-07           0.0            0.0        -1.0  
2019-07-09           1.0            1.0         0.0  
2019-07-10           1.0            0.0         1.0  
2019-10-08           0.0           -1.0         0.0  
2019-10-09           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-16           1.0            1.0         0.0  
2020-04-17           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_007_SlowMA_25_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1051.575866  1048.549922   3.025944   
2019-01-07     1080.97      1075.92  1059.690577  1050.683625   9.006952   
2019-05-01     1197.50      1173.32  1224.228908  1224.328358  -0.099450   
2019-05-02     1172.60      1166.51  1204.989272  1219.880694 -14.891422   
2019-06-24     1120.00      1116.70  1112.156078  1111.140161   1.015917   
2019-06-25     1115.08      1087.58  1103.964052  1109.327839  -5.363787   
2019-06-26     1091.00      1080.32  1096.082701  1107.096465 -11.013763   
2019-07-03     1118.50      1122.99  1106.709944  1105.073216   1.636728   
2019-07-05     1119.37      1132.66  1115.359963  1107.195278   8.164685   
2019-08-26     1159.45      1171.18  1174.951108  1175.350570  -0.399462   
2019-08-27     1183.00      1170.82  1173.574072  1175.002065  -1.427993   
2019-08-29     1186.42      1194.24  1180.501810  1176.393002   4.108808   
2019-08-30     1200.35      1190.53  1183.844540  1177.480463   6.364076   
2019-10-02     1196.50      1177.92  1206.917342  1212.873522  -5.956180   
2019-10-03     1183.34      1189.43  1201.088228  1211.070174  -9.981946   
2019-10-14     1213.89      1217.77  1211.151131  1209.965458   1.185673   
2019-10-15     1221.50      1242.24  1221.514087  1212.448115   9.065972   
2020-02-25     1431.00      1386.32  1446.815629  1465.467016 -18.651387   
2020-02-26     1394.98      1390.47  1428.033753  1459.698015 -31.664262   
2020-04-13     1201.50      1210.41  1191.712794  1187.138583   4.574211   
2020-04-14     1239.97      1265.23  1216.218529  1193.145615  23.072914   
2020-06-26     1432.63      1362.54  1415.499219  1417.939242  -2.440024   
2020-06-29     1360.34      1397.17  1409.389479  1416.341608  -6.952129   
2020-07-01     1419.17      1442.00  1422.184213  1418.436637   3.747576   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-05-01           0.0           -1.0         0.0  
2019-05-02           0.0            0.0        -1.0  
2019-06-24           1.0            1.0         0.0  
2019-06-25           0.0           -1.0         1.0  
2019-06-26           0.0            0.0        -1.0  
2019-07-03           1.0            1.0         0.0  
2019-07-05           1.0            0.0         1.0  
2019-08-26           0.0           -1.0         0.0  
2019-08-27           0.0            0.0        -1.0  
2019-08-29           1.0            1.0         0.0  
2019-08-30           1.0            0.0         1.0  
2019-10-02           0.0           -1.0         0.0  
2019-10-03           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2020-02-25           0.0           -1.0         0.0  
2020-02-26           0.0            0.0        -1.0  
2020-04-13           1.0            1.0         0.0  
2020-04-14           1.0            0.0         1.0  
2020-06-26           0.0           -1.0         0.0  
2020-06-29           0.0            0.0        -1.0  
2020-07-01           1.0            1.0         0.0  

List the signal change and entry/exit points for EMA_008_SlowMA_25_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-07     1080.97      1075.92  1051.261500  1050.683625   0.577874   
2019-01-08     1086.00      1085.37  1057.463145  1053.384894   4.078251   
2019-05-03     1177.41      1189.55  1216.485533  1217.547517  -1.061984   
2019-05-06     1172.00      1193.46  1212.299072  1215.694596  -3.395524   
2019-07-08     1125.87      1116.79  1108.893854  1107.933334   0.960520   
2019-07-09     1110.32      1124.29  1111.693153  1109.191540   2.501614   
2019-10-07     1207.00      1208.25  1210.685358  1210.845415  -0.160057   
2019-10-08     1198.77      1190.13  1206.948020  1209.251921  -2.303901   
2019-10-14     1213.89      1217.77  1210.073139  1209.965458   0.107680   
2019-10-15     1221.50      1242.24  1215.921659  1212.448115   3.473544   
2020-02-26     1394.98      1390.47  1454.628971  1459.698015  -5.069044   
2020-02-27     1359.14      1314.95  1429.232794  1448.563553 -19.330758   
2020-04-15     1246.51      1257.30  1201.496785  1198.080567   3.416218   
2020-04-16     1267.14      1257.43  1211.666460  1202.645908   9.020552   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-07           1.0            1.0         0.0  
2019-01-08           1.0            0.0         1.0  
2019-05-03           0.0           -1.0         0.0  
2019-05-06           0.0            0.0        -1.0  
2019-07-08           1.0            1.0         0.0  
2019-07-09           1.0            0.0         1.0  
2019-10-07           0.0           -1.0         0.0  
2019-10-08           0.0            0.0        -1.0  
2019-10-14           1.0            1.0         0.0  
2019-10-15           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-15           1.0            1.0         0.0  
2020-04-16           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_009_SlowMA_25_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1053.917767  1053.384894   0.532872   
2019-01-09     1087.99      1081.65  1057.386257  1055.583997   1.802260   
2019-05-07     1185.81      1178.86  1212.492803  1212.861117  -0.368314   
2019-05-08     1177.29      1170.78  1207.278702  1209.624056  -2.345354   
2019-07-10     1132.32      1140.91  1112.335629  1111.631422   0.704207   
2019-07-11     1146.16      1144.08  1116.303675  1114.127468   2.176207   
2020-02-27     1359.14      1314.95  1443.931989  1448.563553  -4.631564   
2020-02-28     1274.31      1339.25  1430.846740  1440.154818  -9.308078   
2020-04-17     1281.70      1279.00  1208.737761  1208.519300   0.218461   
2020-04-20     1269.89      1261.15  1215.289291  1212.567815   2.721476   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-07           0.0           -1.0         0.0  
2019-05-08           0.0            0.0        -1.0  
2019-07-10           1.0            1.0         0.0  
2019-07-11           1.0            0.0         1.0  
2020-02-27           0.0           -1.0         0.0  
2020-02-28           0.0            0.0        -1.0  
2020-04-17           1.0            1.0         0.0  
2020-04-20           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_010_SlowMA_25_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1055.876077  1055.583997   0.292080   
2019-01-10     1074.94      1078.83  1058.069469  1057.391010   0.678459   
2019-05-09     1162.60      1167.97  1205.843656  1206.419851  -0.576195   
2019-05-10     1168.84      1167.64  1202.205210  1203.436745  -1.231535   
2019-07-12     1142.93      1145.34  1117.030017  1116.528433   0.501584   
2019-07-15     1145.34      1150.51  1120.218587  1119.142401   1.076186   
2020-02-28     1274.31      1339.25  1438.249751  1440.154818  -1.905067   
2020-03-02     1351.39      1386.32  1433.304060  1436.013678  -2.709617   
2020-04-23     1265.74      1271.17  1220.518389  1220.304012   0.214377   
2020-04-24     1255.00      1276.60  1225.859495  1224.634473   1.225022   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-09           0.0           -1.0         0.0  
2019-05-10           0.0            0.0        -1.0  
2019-07-12           1.0            1.0         0.0  
2019-07-15           1.0            0.0         1.0  
2020-02-28           0.0           -1.0         0.0  
2020-03-02           0.0            0.0        -1.0  
2020-04-23           1.0            1.0         0.0  
2020-04-24           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_011_SlowMA_30_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1051.575866  1050.005256   1.570610   
2019-01-07     1080.97      1075.92  1059.690577  1051.724077   7.966500   
2019-05-02     1172.60      1166.51  1204.989272  1215.542393 -10.553121   
2019-05-03     1177.41      1189.55  1199.842848  1213.865258 -14.022410   
2019-07-05     1119.37      1132.66  1115.359963  1110.463799   4.896163   
2019-07-08     1125.87      1116.79  1115.836642  1110.871944   4.964698   
2019-10-02     1196.50      1177.92  1206.917342  1209.822724  -2.905381   
2019-10-03     1183.34      1189.43  1201.088228  1208.507064  -7.418836   
2019-10-11     1224.03      1215.71  1207.841696  1207.815131   0.026566   
2019-10-14     1213.89      1217.77  1211.151131  1208.457380   2.693751   
2020-02-25     1431.00      1386.32  1446.815629  1459.322958 -12.507329   
2020-02-26     1394.98      1390.47  1428.033753  1454.880832 -26.847079   
2020-04-14     1239.97      1265.23  1216.218529  1204.336412  11.882117   
2020-04-15     1246.51      1257.30  1229.912353  1207.753417  22.158935   
2020-06-29     1360.34      1397.17  1409.389479  1410.346880  -0.957401   
2020-06-30     1396.88      1418.05  1412.276319  1410.843855   1.432464   
2020-07-01     1419.17      1442.00  1422.184213  1412.853929   9.330284   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-05-02           0.0           -1.0         0.0  
2019-05-03           0.0            0.0        -1.0  
2019-07-05           1.0            1.0         0.0  
2019-07-08           1.0            0.0         1.0  
2019-10-02           0.0           -1.0         0.0  
2019-10-03           0.0            0.0        -1.0  
2019-10-11           1.0            1.0         0.0  
2019-10-14           1.0            0.0         1.0  
2020-02-25           0.0           -1.0         0.0  
2020-02-26           0.0            0.0        -1.0  
2020-04-14           1.0            1.0         0.0  
2020-04-15           1.0            0.0         1.0  
2020-06-29           0.0           -1.0         0.0  
2020-06-30           1.0            1.0        -1.0  
2020-07-01           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_012_SlowMA_30_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1057.463145  1053.951645   3.511500   
2019-01-09     1087.99      1081.65  1061.860813  1055.782353   6.078460   
2019-05-06     1172.00      1193.46  1212.299072  1212.548638  -0.249566   
2019-05-07     1185.81      1178.86  1206.219241  1210.374944  -4.155703   
2019-07-10     1132.32      1140.91  1117.005307  1113.619729   3.385578   
2019-07-11     1146.16      1144.08  1121.927979  1115.584919   6.343060   
2019-10-08     1198.77      1190.13  1206.948020  1207.444425  -0.496404   
2019-10-09     1201.33      1202.40  1206.121108  1207.118978  -0.997870   
2019-10-11     1224.03      1215.71  1208.362725  1207.815131   0.547594   
2019-10-14     1213.89      1217.77  1210.073139  1208.457380   1.615758   
2020-02-26     1394.98      1390.47  1454.628971  1454.880832  -0.251861   
2020-02-27     1359.14      1314.95  1429.232794  1445.853036 -16.620242   
2020-04-16     1267.14      1257.43  1211.666460  1210.958358   0.708102   
2020-04-17     1281.70      1279.00  1223.908922  1215.348141   8.560781   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-06           0.0           -1.0         0.0  
2019-05-07           0.0            0.0        -1.0  
2019-07-10           1.0            1.0         0.0  
2019-07-11           1.0            0.0         1.0  
2019-10-08           0.0           -1.0         0.0  
2019-10-09           0.0            0.0        -1.0  
2019-10-11           1.0            1.0         0.0  
2019-10-14           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-16           1.0            1.0         0.0  
2020-04-17           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_013_SlowMA_30_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1057.386257  1055.782353   1.603905   
2019-01-10     1074.94      1078.83  1060.068052  1057.303274   2.764778   
2019-05-08     1177.29      1170.78  1207.278702  1207.820174  -0.541472   
2019-05-09     1162.60      1167.97  1202.365115  1205.248953  -2.883838   
2019-07-11     1146.16      1144.08  1116.303675  1115.584919   0.718757   
2019-07-12     1142.93      1145.34  1119.933216  1117.504611   2.428605   
2020-02-27     1359.14      1314.95  1443.931989  1445.853036  -1.921048   
2020-02-28     1274.31      1339.25  1430.846740  1438.975421  -8.128681   
2020-04-23     1265.74      1271.17  1226.691224  1223.787632   2.903592   
2020-04-24     1255.00      1276.60  1232.929821  1227.194882   5.734940   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-08           0.0           -1.0         0.0  
2019-05-09           0.0            0.0        -1.0  
2019-07-11           1.0            1.0         0.0  
2019-07-12           1.0            0.0         1.0  
2020-02-27           0.0           -1.0         0.0  
2020-02-28           0.0            0.0        -1.0  
2020-04-23           1.0            1.0         0.0  
2020-04-24           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_014_SlowMA_30_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1055.876077  1055.782353   0.093725   
2019-01-10     1074.94      1078.83  1058.069469  1057.303274   0.766195   
2019-05-10     1168.84      1167.64  1202.205210  1202.822355  -0.617145   
2019-05-13     1145.24      1136.59  1195.956138  1198.548947  -2.592810   
2019-07-15     1145.34      1150.51  1120.218587  1119.634001   0.584586   
2019-07-16     1146.73      1153.46  1123.384436  1121.816333   1.568103   
2020-02-28     1274.31      1339.25  1438.249751  1438.975421  -0.725670   
2020-03-02     1351.39      1386.32  1433.304060  1435.578297  -2.274237   
2020-04-27     1292.00      1270.86  1230.145257  1230.011986   0.133271   
2020-04-28     1283.20      1232.59  1230.378090  1230.178310   0.199781   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-10           0.0           -1.0         0.0  
2019-05-13           0.0            0.0        -1.0  
2019-07-15           1.0            1.0         0.0  
2019-07-16           1.0            0.0         1.0  
2020-02-28           0.0           -1.0         0.0  
2020-03-02           0.0            0.0        -1.0  
2020-04-27           1.0            1.0         0.0  
2020-04-28           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_015_SlowMA_35_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1051.575866  1051.266297   0.309569   
2019-01-07     1080.97      1075.92  1059.690577  1052.701476   6.989101   
2019-05-02     1172.60      1166.51  1204.989272  1210.852394  -5.863121   
2019-05-03     1177.41      1189.55  1199.842848  1209.668400  -9.825552   
2019-07-05     1119.37      1132.66  1115.359963  1113.994334   1.365629   
2019-07-08     1125.87      1116.79  1115.836642  1114.149654   1.686988   
2019-10-03     1183.34      1189.43  1201.088228  1205.720051  -4.631823   
2019-10-04     1194.29      1210.96  1204.378819  1206.011160  -1.632341   
2019-10-11     1224.03      1215.71  1207.841696  1205.908221   1.933476   
2019-10-14     1213.89      1217.77  1211.151131  1206.567209   4.583922   
2020-02-25     1431.00      1386.32  1446.815629  1452.577673  -5.762044   
2020-02-26     1394.98      1390.47  1428.033753  1449.127247 -21.093494   
2020-04-14     1239.97      1265.23  1216.218529  1215.737194   0.481335   
2020-04-15     1246.51      1257.30  1229.912353  1218.046239  11.866113   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-01-07           1.0            0.0         1.0  
2019-05-02           0.0           -1.0         0.0  
2019-05-03           0.0            0.0        -1.0  
2019-07-05           1.0            1.0         0.0  
2019-07-08           1.0            0.0         1.0  
2019-10-03           0.0           -1.0         0.0  
2019-10-04           0.0            0.0        -1.0  
2019-10-11           1.0            1.0         0.0  
2019-10-14           1.0            0.0         1.0  
2020-02-25           0.0           -1.0         0.0  
2020-02-26           0.0            0.0        -1.0  
2020-04-14           1.0            1.0         0.0  
2020-04-15           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_016_SlowMA_35_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1057.463145  1054.598185   2.864960   
2019-01-09     1087.99      1081.65  1061.860813  1056.164869   5.695944   
2019-05-07     1185.81      1178.86  1206.219241  1207.105363  -0.886122   
2019-05-08     1177.29      1170.78  1199.775743  1205.086530  -5.310787   
2019-07-10     1132.32      1140.91  1117.005307  1116.168460   0.836847   
2019-07-11     1146.16      1144.08  1121.927979  1117.719148   4.208830   
2020-02-27     1359.14      1314.95  1429.232794  1441.672955 -12.440161   
2020-02-28     1274.31      1339.25  1412.872286  1435.982791 -23.110505   
2020-04-17     1281.70      1279.00  1223.908922  1223.498991   0.409931   
2020-04-20     1269.89      1261.15  1230.680027  1225.590714   5.089313   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-07           0.0           -1.0         0.0  
2019-05-08           0.0            0.0        -1.0  
2019-07-10           1.0            1.0         0.0  
2019-07-11           1.0            0.0         1.0  
2020-02-27           0.0           -1.0         0.0  
2020-02-28           0.0            0.0        -1.0  
2020-04-17           1.0            1.0         0.0  
2020-04-20           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_017_SlowMA_35_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1057.386257  1056.164869   1.221388   
2019-01-10     1074.94      1078.83  1060.068052  1057.474414   2.593639   
2019-05-09     1162.60      1167.97  1202.365115  1203.023769  -0.658655   
2019-05-10     1168.84      1167.64  1198.024475  1201.057346  -3.032871   
2019-07-12     1142.93      1145.34  1119.933216  1119.253684   0.679532   
2019-07-15     1145.34      1150.51  1123.755314  1120.990193   2.765121   
2020-02-28     1274.31      1339.25  1430.846740  1435.982791  -5.136051   
2020-03-02     1351.39      1386.32  1425.280898  1433.223747  -7.942849   
2020-04-24     1255.00      1276.60  1232.929821  1231.813829   1.115993   
2020-04-27     1292.00      1270.86  1237.671094  1233.983060   3.688033   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-09           0.0           -1.0         0.0  
2019-05-10           0.0            0.0        -1.0  
2019-07-12           1.0            1.0         0.0  
2019-07-15           1.0            0.0         1.0  
2020-02-28           0.0           -1.0         0.0  
2020-03-02           0.0            0.0        -1.0  
2020-04-24           1.0            1.0         0.0  
2020-04-27           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_018_SlowMA_35_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-10     1074.94      1078.83  1058.069469  1057.474414   0.595055   
2019-01-11     1069.90      1064.47  1058.680886  1057.877708   0.803178   
2019-05-13     1145.24      1136.59  1195.956138  1197.474694  -1.518557   
2019-05-14     1142.32      1124.86  1189.185072  1193.439340  -4.254267   
2019-07-16     1146.73      1153.46  1123.384436  1122.794117   0.590318   
2019-07-17     1150.92      1146.74  1125.608775  1124.124476   1.484299   
2020-03-03     1397.68      1337.72  1424.200817  1427.917983  -3.717167   
2020-03-04     1358.96      1381.60  1420.143596  1425.344762  -5.201166   
2020-04-29     1345.00      1342.18  1241.025891  1239.920909   1.104982   
2020-04-30     1331.36      1346.70  1251.090092  1245.853081   5.237011   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-10           1.0            1.0         0.0  
2019-01-11           1.0            0.0         1.0  
2019-05-13           0.0           -1.0         0.0  
2019-05-14           0.0            0.0        -1.0  
2019-07-16           1.0            1.0         0.0  
2019-07-17           1.0            0.0         1.0  
2020-03-03           0.0           -1.0         0.0  
2020-03-04           0.0            0.0        -1.0  
2020-04-29           1.0            1.0         0.0  
2020-04-30           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_019_SlowMA_40_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-07     1080.97      1075.92  1059.690577  1053.571229   6.119349   
2019-01-08     1086.00      1085.37  1068.250385  1055.228258  13.022127   
2019-05-02     1172.60      1166.51  1204.989272  1206.082966  -1.093693   
2019-05-03     1177.41      1189.55  1199.842848  1205.275535  -5.432687   
2019-07-09     1110.32      1124.29  1118.654428  1117.712131   0.942297   
2019-07-10     1132.32      1140.91  1126.072952  1118.843867   7.229085   
2019-10-03     1183.34      1189.43  1201.088228  1202.911479  -1.823251   
2019-10-04     1194.29      1210.96  1204.378819  1203.304092   1.074727   
2019-10-07     1207.00      1208.25  1205.669213  1203.545357   2.123855   
2019-10-08     1198.77      1190.13  1200.489475  1202.890946  -2.401471   
2019-10-09     1201.33      1202.40  1201.126317  1202.866997  -1.740681   
2019-10-10     1198.60      1209.47  1203.907544  1203.189097   0.718448   
2019-10-11     1224.03      1215.71  1207.841696  1203.799875   4.041821   
2020-02-26     1394.98      1390.47  1428.033753  1442.889722 -14.855970   
2020-02-27     1359.14      1314.95  1390.339169  1436.648760 -46.309592   
2020-04-15     1246.51      1257.30  1229.912353  1227.942098   1.970255   
2020-04-16     1267.14      1257.43  1239.084902  1229.380532   9.704370   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-07           1.0            1.0         0.0  
2019-01-08           1.0            0.0         1.0  
2019-05-02           0.0           -1.0         0.0  
2019-05-03           0.0            0.0        -1.0  
2019-07-09           1.0            1.0         0.0  
2019-07-10           1.0            0.0         1.0  
2019-10-03           0.0           -1.0         0.0  
2019-10-04           1.0            1.0        -1.0  
2019-10-07           1.0            0.0         1.0  
2019-10-08           0.0           -1.0         0.0  
2019-10-09           0.0            0.0        -1.0  
2019-10-10           1.0            1.0         0.0  
2019-10-11           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-15           1.0            1.0         0.0  
2020-04-16           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_020_SlowMA_40_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1057.463145  1055.228258   2.234887   
2019-01-09     1087.99      1081.65  1061.860813  1056.600522   5.260291   
2019-05-08     1177.29      1170.78  1199.775743  1201.842157  -2.066415   
2019-05-09     1162.60      1167.97  1193.992880  1200.188274  -6.195393   
2019-07-11     1146.16      1144.08  1121.927979  1120.075035   1.852944   
2019-07-12     1142.93      1145.34  1126.184710  1121.307603   4.877107   
2020-02-27     1359.14      1314.95  1429.232794  1436.648760  -7.415966   
2020-02-28     1274.31      1339.25  1412.872286  1431.897601 -19.025315   
2020-04-23     1265.74      1271.17  1239.912832  1235.321414   4.591418   
2020-04-24     1255.00      1276.60  1246.583226  1237.335004   9.248223   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-08           0.0           -1.0         0.0  
2019-05-09           0.0            0.0        -1.0  
2019-07-11           1.0            1.0         0.0  
2019-07-12           1.0            0.0         1.0  
2020-02-27           0.0           -1.0         0.0  
2020-02-28           0.0            0.0        -1.0  
2020-04-23           1.0            1.0         0.0  
2020-04-24           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_021_SlowMA_40_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1057.386257  1056.600522   0.785735   
2019-01-10     1074.94      1078.83  1060.068052  1057.751420   2.316632   
2019-05-10     1168.84      1167.64  1198.024475  1198.599106  -0.574631   
2019-05-13     1145.24      1136.59  1190.345166  1195.571649  -5.226484   
2019-07-15     1145.34      1150.51  1123.755314  1122.732254   1.023060   
2019-07-16     1146.73      1153.46  1127.468400  1124.231312   3.237088   
2020-02-28     1274.31      1339.25  1430.846740  1431.897601  -1.050861   
2020-03-02     1351.39      1386.32  1425.280898  1429.674303  -4.393406   
2020-04-29     1345.00      1342.18  1250.178962  1243.708930   6.470032   
2020-04-30     1331.36      1346.70  1262.244092  1248.732885  13.511207   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-10           0.0           -1.0         0.0  
2019-05-13           0.0            0.0        -1.0  
2019-07-15           1.0            1.0         0.0  
2019-07-16           1.0            0.0         1.0  
2020-02-28           0.0           -1.0         0.0  
2020-03-02           0.0            0.0        -1.0  
2020-04-29           1.0            1.0         0.0  
2020-04-30           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_022_SlowMA_40_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-10     1074.94      1078.83  1058.069469  1057.751420   0.318049   
2019-01-11     1069.90      1064.47  1058.680886  1058.098227   0.582659   
2019-05-14     1142.32      1124.86  1189.185072  1192.119456  -2.934384   
2019-05-15     1122.55      1170.80  1187.434112  1191.078667  -3.644555   
2019-07-17     1150.92      1146.74  1125.608775  1125.329397   0.279378   
2019-07-18     1142.00      1147.24  1127.668892  1126.398300   1.270592   
2020-03-03     1397.68      1337.72  1424.200817  1425.188727  -0.987911   
2020-03-04     1358.96      1381.60  1420.143596  1423.062448  -2.918852   
2020-04-30     1331.36      1346.70  1251.090092  1248.732885   2.357207   
2020-05-01     1324.09      1317.32  1257.397702  1252.078598   5.319104   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-10           1.0            1.0         0.0  
2019-01-11           1.0            0.0         1.0  
2019-05-14           0.0           -1.0         0.0  
2019-05-15           0.0            0.0        -1.0  
2019-07-17           1.0            1.0         0.0  
2019-07-18           1.0            0.0         1.0  
2020-03-03           0.0           -1.0         0.0  
2020-03-04           0.0            0.0        -1.0  
2020-04-30           1.0            1.0         0.0  
2020-05-01           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_023_SlowMA_45_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-07     1080.97      1075.92  1059.690577  1054.330610   5.359967   
2019-01-08     1086.00      1085.37  1068.250385  1055.808325  12.442060   
2019-05-03     1177.41      1189.55  1199.842848  1200.886752  -1.043903   
2019-05-06     1172.00      1193.46  1197.715232  1200.563083  -2.847851   
2019-07-10     1132.32      1140.91  1126.072952  1121.398642   4.674310   
2019-07-11     1146.16      1144.08  1132.075301  1122.385090   9.690211   
2019-10-08     1198.77      1190.13  1200.489475  1200.518973  -0.029498   
2019-10-09     1201.33      1202.40  1201.126317  1200.600758   0.525558   
2019-10-10     1198.60      1209.47  1203.907544  1200.986384   2.921160   
2020-02-26     1394.98      1390.47  1428.033753  1436.428995  -8.395242   
2020-02-27     1359.14      1314.95  1390.339169  1431.147298 -40.808130   
2020-04-16     1267.14      1257.43  1239.084902  1237.865940   1.218962   
2020-04-17     1281.70      1279.00  1252.389935  1239.654377  12.735557   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-07           1.0            1.0         0.0  
2019-01-08           1.0            0.0         1.0  
2019-05-03           0.0           -1.0         0.0  
2019-05-06           0.0            0.0        -1.0  
2019-07-10           1.0            1.0         0.0  
2019-07-11           1.0            0.0         1.0  
2019-10-08           0.0           -1.0         0.0  
2019-10-09           1.0            1.0        -1.0  
2019-10-10           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-16           1.0            1.0         0.0  
2020-04-17           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_024_SlowMA_45_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1057.463145  1055.808325   1.654820   
2019-01-09     1087.99      1081.65  1061.860813  1057.033529   4.827284   
2019-05-09     1162.60      1167.97  1193.992880  1197.036724  -3.043843   
2019-05-10     1168.84      1167.64  1189.201447  1195.756066  -6.554618   
2019-07-12     1142.93      1145.34  1126.184710  1123.383422   2.801287   
2019-07-15     1145.34      1150.51  1130.607490  1124.563170   6.044320   
2020-02-27     1359.14      1314.95  1429.232794  1431.147298  -1.914504   
2020-02-28     1274.31      1339.25  1412.872286  1427.151762 -14.279476   
2020-04-24     1255.00      1276.60  1246.583226  1243.053656   3.529570   
2020-04-27     1292.00      1270.86  1250.997185  1244.262628   6.734558   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-09           0.0           -1.0         0.0  
2019-05-10           0.0            0.0        -1.0  
2019-07-12           1.0            1.0         0.0  
2019-07-15           1.0            0.0         1.0  
2020-02-27           0.0           -1.0         0.0  
2020-02-28           0.0            0.0        -1.0  
2020-04-24           1.0            1.0         0.0  
2020-04-27           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_025_SlowMA_45_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-09     1087.99      1081.65  1057.386257  1057.033529   0.352728   
2019-01-10     1074.94      1078.83  1060.068052  1058.062893   2.005159   
2019-05-13     1145.24      1136.59  1190.345166  1193.178740  -2.833574   
2019-05-14     1142.32      1124.86  1182.159520  1190.202962  -8.043442   
2019-07-16     1146.73      1153.46  1127.468400  1125.819891   1.648509   
2019-07-17     1150.92      1146.74  1129.877350  1126.729694   3.147656   
2020-03-02     1351.39      1386.32  1425.280898  1425.376468  -0.095570   
2020-03-03     1397.68      1337.72  1414.335785  1421.565316  -7.229531   
2020-04-29     1345.00      1342.18  1250.178962  1248.034465   2.144498   
2020-04-30     1331.36      1346.70  1262.244092  1252.324271   9.919821   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-09           1.0            1.0         0.0  
2019-01-10           1.0            0.0         1.0  
2019-05-13           0.0           -1.0         0.0  
2019-05-14           0.0            0.0        -1.0  
2019-07-16           1.0            1.0         0.0  
2019-07-17           1.0            0.0         1.0  
2020-03-02           0.0           -1.0         0.0  
2020-03-03           0.0            0.0        -1.0  
2020-04-29           1.0            1.0         0.0  
2020-04-30           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_026_SlowMA_45_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-10     1074.94      1078.83  1058.069469  1058.062893   0.006576   
2019-01-11     1069.90      1064.47  1058.680886  1058.364346   0.316540   
2019-01-14     1053.34      1051.51  1057.996077  1058.042998  -0.046921   
2019-01-15     1058.01      1086.51  1060.718403  1059.373071   1.345332   
2019-01-16     1090.00      1089.51  1063.466593  1060.776614   2.689978   
2019-05-14     1142.32      1124.86  1189.185072  1190.202962  -1.017889   
2019-05-15     1122.55      1170.80  1187.434112  1189.357888  -1.923776   
2019-07-18     1142.00      1147.24  1127.668892  1127.621665   0.047226   
2019-07-19     1149.32      1131.55  1128.038521  1127.792503   0.246018   
2020-03-05     1345.55      1314.76  1410.107063  1415.259532  -5.152469   
2020-03-06     1269.95      1295.74  1399.214962  1410.063030 -10.848068   
2020-05-01     1324.09      1317.32  1257.397702  1255.150172   2.247530   
2020-05-04     1308.13      1322.90  1263.636016  1258.095817   5.540199   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-10           1.0            1.0         0.0  
2019-01-11           1.0            0.0         1.0  
2019-01-14           0.0           -1.0         0.0  
2019-01-15           1.0            1.0        -1.0  
2019-01-16           1.0            0.0         1.0  
2019-05-14           0.0           -1.0         0.0  
2019-05-15           0.0            0.0        -1.0  
2019-07-18           1.0            1.0         0.0  
2019-07-19           1.0            0.0         1.0  
2020-03-05           0.0           -1.0         0.0  
2020-03-06           0.0            0.0        -1.0  
2020-05-01           1.0            1.0         0.0  
2020-05-04           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_027_SlowMA_50_FastMA_05
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-07     1080.97      1075.92  1059.690577  1054.990327   4.700250   
2019-01-08     1086.00      1085.37  1068.250385  1056.330093  11.920291   
2019-05-07     1185.81      1178.86  1191.430155  1195.807023  -4.376868   
2019-05-08     1177.29      1170.78  1184.546770  1194.821627 -10.274857   
2019-07-10     1132.32      1140.91  1126.072952  1123.708188   2.364764   
2019-07-11     1146.16      1144.08  1132.075301  1124.507633   7.567668   
2020-02-26     1394.98      1390.47  1428.033753  1429.902040  -1.868287   
2020-02-27     1359.14      1314.95  1390.339169  1425.394112 -35.054943   
2020-04-17     1281.70      1279.00  1252.389935  1246.781579   5.608356   
2020-04-20     1269.89      1261.15  1255.309956  1247.345046   7.964910   
2020-04-21     1242.71      1212.16  1240.926638  1245.965240  -5.038603   
2020-04-22     1241.11      1258.41  1246.754425  1246.453270   0.301155   
2020-04-23     1265.74      1271.17  1254.892950  1247.422554   7.470396   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-07           1.0            1.0         0.0  
2019-01-08           1.0            0.0         1.0  
2019-05-07           0.0           -1.0         0.0  
2019-05-08           0.0            0.0        -1.0  
2019-07-10           1.0            1.0         0.0  
2019-07-11           1.0            0.0         1.0  
2020-02-26           0.0           -1.0         0.0  
2020-02-27           0.0            0.0        -1.0  
2020-04-17           1.0            1.0         0.0  
2020-04-20           1.0            0.0         1.0  
2020-04-21           0.0           -1.0         0.0  
2020-04-22           1.0            1.0        -1.0  
2020-04-23           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_028_SlowMA_50_FastMA_10
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-08     1086.00      1085.37  1057.463145  1056.330093   1.133051   
2019-01-09     1087.99      1081.65  1061.860813  1057.441292   4.419521   
2019-05-10     1168.84      1167.64  1189.201447  1192.736264  -3.534817   
2019-05-13     1145.24      1136.59  1179.635730  1190.526605 -10.890876   
2019-07-12     1142.93      1145.34  1126.184710  1125.325129   0.859580   
2019-07-15     1145.34      1150.51  1130.607490  1126.313400   4.294090   
2020-02-28     1274.31      1339.25  1412.872286  1422.015907  -9.143621   
2020-03-02     1351.39      1386.32  1408.044598  1420.616066 -12.571468   
2020-04-27     1292.00      1270.86  1250.997185  1249.441012   1.556173   
2020-04-28     1283.20      1232.59  1247.650424  1248.780188  -1.129764   
2020-04-29     1345.00      1342.18  1264.837620  1252.442927  12.394693   
2020-04-30     1331.36      1346.70  1279.721689  1256.139283  23.582406   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-08           1.0            1.0         0.0  
2019-01-09           1.0            0.0         1.0  
2019-05-10           0.0           -1.0         0.0  
2019-05-13           0.0            0.0        -1.0  
2019-07-12           1.0            1.0         0.0  
2019-07-15           1.0            0.0         1.0  
2020-02-28           0.0           -1.0         0.0  
2020-03-02           0.0            0.0        -1.0  
2020-04-27           1.0            1.0         0.0  
2020-04-28           0.0           -1.0         1.0  
2020-04-29           1.0            1.0        -1.0  
2020-04-30           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_029_SlowMA_50_FastMA_15
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-10     1074.94      1078.83  1060.068052  1058.375601   1.692451   
2019-01-11     1069.90      1064.47  1060.618534  1058.640635   1.977899   
2019-05-13     1145.24      1136.59  1190.345166  1190.526605  -0.181439   
2019-05-14     1142.32      1124.86  1182.159520  1187.942630  -5.783110   
2019-07-16     1146.73      1153.46  1127.468400  1127.378623   0.089777   
2019-07-17     1150.92      1146.74  1129.877350  1128.138338   1.739012   
2020-03-03     1397.68      1337.72  1414.335785  1417.365237  -3.029451   
2020-03-04     1358.96      1381.60  1410.243812  1415.962677  -5.718865   
2020-04-30     1331.36      1346.70  1262.244092  1256.139283   6.104809   
2020-05-01     1324.09      1317.32  1269.128581  1258.538528  10.590053   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-10           1.0            1.0         0.0  
2019-01-11           1.0            0.0         1.0  
2019-05-13           0.0           -1.0         0.0  
2019-05-14           0.0            0.0        -1.0  
2019-07-16           1.0            1.0         0.0  
2019-07-17           1.0            0.0         1.0  
2020-03-03           0.0           -1.0         0.0  
2020-03-04           0.0            0.0        -1.0  
2020-04-30           1.0            1.0         0.0  
2020-05-01           1.0            0.0         1.0  

List the signal change and entry/exit points for EMA_030_SlowMA_50_FastMA_20
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-11     1069.90      1064.47  1058.680886  1058.640635   0.040251   
2019-01-14     1053.34      1051.51  1057.996077  1058.331856  -0.335779   
2019-01-15     1058.01      1086.51  1060.718403  1059.547090   1.171314   
2019-01-16     1090.00      1089.51  1063.466593  1060.834260   2.632332   
2019-05-16     1171.84      1184.50  1187.154673  1187.159262  -0.004589   
2019-05-17     1175.83      1168.78  1185.404703  1186.436319  -1.031617   
2019-07-23     1143.45      1148.05  1130.906998  1130.125208   0.781790   
2019-07-24     1132.62      1139.73  1131.747284  1130.502047   1.245236   
2020-03-05     1345.55      1314.76  1410.107063  1411.993941  -1.886878   
2020-03-06     1269.95      1295.74  1399.214962  1407.434958  -8.219997   
2020-05-04     1308.13      1322.90  1263.636016  1261.062507   2.573509   
2020-05-05     1337.50      1349.02  1271.767824  1264.511821   7.256003   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-11           1.0            1.0         0.0  
2019-01-14           0.0           -1.0         1.0  
2019-01-15           1.0            1.0        -1.0  
2019-01-16           1.0            0.0         1.0  
2019-05-16           0.0           -1.0         0.0  
2019-05-17           0.0            0.0        -1.0  
2019-07-23           1.0            1.0         0.0  
2019-07-24           1.0            0.0         1.0  
2020-03-05           0.0           -1.0         0.0  
2020-03-06           0.0            0.0        -1.0  
2020-05-04           1.0            1.0         0.0  
2020-05-05           1.0            0.0         1.0  

In [15]:
if verbose:
    for key in model_collection:
        graph_data = model_collection[key].copy()
        title_string = "Exponential Moving Average Crossover Model for " + key
        fig = plt.figure(figsize=(16,9))
        ylabel = stock_symbol + ' price in $'
        ax1 = fig.add_subplot(111, ylabel=ylabel, title=title_string)
        graph_data['fast_ma'].plot(ax=ax1, color='b', lw=2.)
        graph_data['slow_ma'].plot(ax=ax1, color='r', lw=2.)
        graph_data['close_price'].plot(ax=ax1, color='g')
        ax1.plot(graph_data.loc[graph_data.entry_exit == 1].index, graph_data.close_price[graph_data.entry_exit == 1], '^', markersize=7, color='k',label='buy')
        ax1.plot(graph_data.loc[graph_data.entry_exit == -1].index, graph_data.close_price[graph_data.entry_exit == -1], 'v', markersize=7, color='k',label='sell')
        plt.legend(loc='upper left')
        plt.show()

Task 4. Back-test Model

In [16]:
def trading_portfolio_generation(initial_fund, trading_model):
    # Construct a portfolio to track the transactions and returns
    portfolio = pd.DataFrame(index=trading_model.index, columns=['trade_action', 'qty_onhand', 'cost_basis', 'sold_transaction', 'gain_loss', 'cash_onhand', 'position_value', 'total_position', 'accumu_return'])
    portfolio.iloc[0]['trade_action'] = 0
    portfolio.iloc[0]['qty_onhand'] = 0
    portfolio.iloc[0]['cost_basis'] = 0.00
    portfolio.iloc[0]['sold_transaction'] = 0.00
    portfolio.iloc[0]['gain_loss'] = 0.00
    portfolio.iloc[0]['cash_onhand'] = initial_capital
    portfolio.iloc[0]['position_value'] = 0.00
    portfolio.iloc[0]['total_position'] = initial_capital
    portfolio.iloc[0]['accumu_return'] = portfolio.iloc[0]['total_position'] - initial_fund
    recent_cost = 0

    # The conditional parameters below determine how the trading strategy will be carried out
    for i in range(1, len(portfolio)):
        if (trading_model.iloc[i]['entry_exit'] == 1) and (portfolio.iloc[i-1]['qty_onhand'] == 0):
            portfolio.iloc[i]['trade_action'] = 1
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand'] + portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['cost_basis'] = trading_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['sold_transaction'] = 0.00
            portfolio.iloc[i]['gain_loss'] = 0.00
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand'] - portfolio.iloc[i]['cost_basis']
            recent_cost = trading_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action']
            if verbose: print('BOUGHT QTY:', portfolio.iloc[i]['trade_action'], 'on', portfolio.index[i], 'at the price of', trading_model.iloc[i]['open_price'])
        elif (trading_model.iloc[i]['entry_exit'] == -1) and (portfolio.iloc[i-1]['qty_onhand'] > 0):
            portfolio.iloc[i]['trade_action'] = -1
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand'] + portfolio.iloc[i]['trade_action']
            portfolio.iloc[i]['cost_basis'] = 0.00
            portfolio.iloc[i]['sold_transaction'] = trading_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action'] * -1
            portfolio.iloc[i]['gain_loss'] = (recent_cost + (trading_model.iloc[i]['open_price'] * portfolio.iloc[i]['trade_action'])) * -1
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand'] + portfolio.iloc[i]['sold_transaction']
            recent_cost = 0.00
            if verbose: print('SOLD QTY:', portfolio.iloc[i]['trade_action'], 'on', portfolio.index[i], 'at the price of', trading_model.iloc[i]['open_price'])
        else:
            portfolio.iloc[i]['trade_action'] = 0
            portfolio.iloc[i]['qty_onhand'] = portfolio.iloc[i-1]['qty_onhand']
            portfolio.iloc[i]['cost_basis'] = portfolio.iloc[i-1]['cost_basis']
            portfolio.iloc[i]['sold_transaction'] = 0.00
            portfolio.iloc[i]['gain_loss'] = 0.00
            portfolio.iloc[i]['cash_onhand'] = portfolio.iloc[i-1]['cash_onhand']
        portfolio.iloc[i]['position_value'] = trading_model.iloc[i]['close_price'] * portfolio.iloc[i]['qty_onhand']
        portfolio.iloc[i]['total_position'] = portfolio.iloc[i]['cash_onhand'] + portfolio.iloc[i]['position_value']
        portfolio.iloc[i]['accumu_return'] = portfolio.iloc[i]['total_position'] - initial_fund

    return portfolio
In [17]:
portfolio_collection = {}

# Build dataframe for reporting model performance summary
performance_summary = pd.DataFrame(columns=['model_name','return_value','return_percent'])

for key in model_collection:
    print('Processing portfolio for model:', key)
    portfolio_collection[key] = trading_portfolio_generation(initial_capital, model_collection[key])
    trade_transactions = portfolio_collection[key][portfolio_collection[key].trade_action != 0]
    print(trade_transactions)
    print('Accumulated profit/loss for one share of stock with initial capital of $%.0f at the end of modeling period: $%.2f' % (initial_capital, portfolio_collection[key].accumu_return[-1]))
    if initial_capital != 0:
        return_percentage = portfolio_collection[key].accumu_return[-1] / initial_capital * 100
        print('Accumulated return percentage based on the initial capital investment: %.2f%%' % (return_percentage))
    else:
        return_percentage = None
    if trade_transactions.iloc[-1]['trade_action'] == 1:
        print('The current status of the model is:', 'Holding a position since', trade_transactions.index.tolist()[-1], '\n')
    else:
        print('The current status of the model is:', 'Waiting to enter since', trade_transactions.index.tolist()[-1], '\n')
    performance_summary = performance_summary.append({'model_name': key, 'return_value': portfolio_collection[key].accumu_return[-1],
                                                      'return_percent': return_percentage}, ignore_index=True)
Processing portfolio for model: EMA_001_SlowMA_10_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-01-30 00:00:00 at the price of 1077.36
BOUGHT QTY: 1 on 2019-01-31 00:00:00 at the price of 1112.24
SOLD QTY: -1 on 2019-02-22 00:00:00 at the price of 1109.7
BOUGHT QTY: 1 on 2019-02-27 00:00:00 at the price of 1114.01
SOLD QTY: -1 on 2019-03-28 00:00:00 at the price of 1175.5
BOUGHT QTY: 1 on 2019-04-03 00:00:00 at the price of 1212.7
SOLD QTY: -1 on 2019-05-02 00:00:00 at the price of 1172.6
BOUGHT QTY: 1 on 2019-06-18 00:00:00 at the price of 1111.5
SOLD QTY: -1 on 2019-06-27 00:00:00 at the price of 1086.75
BOUGHT QTY: 1 on 2019-07-03 00:00:00 at the price of 1118.5
SOLD QTY: -1 on 2019-08-07 00:00:00 at the price of 1157.8
BOUGHT QTY: 1 on 2019-08-09 00:00:00 at the price of 1199.99
SOLD QTY: -1 on 2019-08-13 00:00:00 at the price of 1174.35
BOUGHT QTY: 1 on 2019-08-14 00:00:00 at the price of 1176.07
SOLD QTY: -1 on 2019-08-15 00:00:00 at the price of 1168.43
BOUGHT QTY: 1 on 2019-08-20 00:00:00 at the price of 1195.35
SOLD QTY: -1 on 2019-08-26 00:00:00 at the price of 1159.45
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-09-04 00:00:00 at the price of 1179.45
BOUGHT QTY: 1 on 2019-09-05 00:00:00 at the price of 1193.66
SOLD QTY: -1 on 2019-10-02 00:00:00 at the price of 1196.5
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2019-11-25 00:00:00 at the price of 1296.26
BOUGHT QTY: 1 on 2019-11-26 00:00:00 at the price of 1309.91
SOLD QTY: -1 on 2019-12-03 00:00:00 at the price of 1278.66
BOUGHT QTY: 1 on 2019-12-05 00:00:00 at the price of 1327.0
SOLD QTY: -1 on 2020-01-02 00:00:00 at the price of 1348.41
BOUGHT QTY: 1 on 2020-01-03 00:00:00 at the price of 1348.0
SOLD QTY: -1 on 2020-02-03 00:00:00 at the price of 1461.65
BOUGHT QTY: 1 on 2020-02-04 00:00:00 at the price of 1454.49
SOLD QTY: -1 on 2020-02-06 00:00:00 at the price of 1451.98
BOUGHT QTY: 1 on 2020-02-07 00:00:00 at the price of 1467.38
SOLD QTY: -1 on 2020-02-25 00:00:00 at the price of 1431.0
BOUGHT QTY: 1 on 2020-04-01 00:00:00 at the price of 1124.0
SOLD QTY: -1 on 2020-04-02 00:00:00 at the price of 1100.0
BOUGHT QTY: 1 on 2020-04-07 00:00:00 at the price of 1217.01
SOLD QTY: -1 on 2020-06-15 00:00:00 at the price of 1389.49
BOUGHT QTY: 1 on 2020-06-17 00:00:00 at the price of 1452.94
SOLD QTY: -1 on 2020-06-29 00:00:00 at the price of 1360.34
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-01-30           -1          0          0          1077.36     -3.61   
2019-01-31            1          1    1112.24                0         0   
2019-02-22           -1          0          0           1109.7     -2.54   
2019-02-27            1          1    1114.01                0         0   
2019-03-28           -1          0          0           1175.5     61.49   
2019-04-03            1          1     1212.7                0         0   
2019-05-02           -1          0          0           1172.6     -40.1   
2019-06-18            1          1     1111.5                0         0   
2019-06-27           -1          0          0          1086.75    -24.75   
2019-07-03            1          1     1118.5                0         0   
2019-08-07           -1          0          0           1157.8      39.3   
2019-08-09            1          1    1199.99                0         0   
2019-08-13           -1          0          0          1174.35    -25.64   
2019-08-14            1          1    1176.07                0         0   
2019-08-15           -1          0          0          1168.43     -7.64   
2019-08-20            1          1    1195.35                0         0   
2019-08-26           -1          0          0          1159.45     -35.9   
2019-08-30            1          1    1200.35                0         0   
2019-09-04           -1          0          0          1179.45     -20.9   
2019-09-05            1          1    1193.66                0         0   
2019-10-02           -1          0          0           1196.5      2.84   
2019-10-15            1          1     1221.5                0         0   
2019-11-25           -1          0          0          1296.26     74.76   
2019-11-26            1          1    1309.91                0         0   
2019-12-03           -1          0          0          1278.66    -31.25   
2019-12-05            1          1       1327                0         0   
2020-01-02           -1          0          0          1348.41     21.41   
2020-01-03            1          1       1348                0         0   
2020-02-03           -1          0          0          1461.65    113.65   
2020-02-04            1          1    1454.49                0         0   
2020-02-06           -1          0          0          1451.98     -2.51   
2020-02-07            1          1    1467.38                0         0   
2020-02-25           -1          0          0             1431    -36.38   
2020-04-01            1          1       1124                0         0   
2020-04-02           -1          0          0             1100       -24   
2020-04-07            1          1    1217.01                0         0   
2020-06-15           -1          0          0          1389.49    172.48   
2020-06-17            1          1    1452.94                0         0   
2020-06-29           -1          0          0          1360.34     -92.6   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-01-30       -3.61              0          -3.61         -3.61  
2019-01-31    -1115.85        1125.89          10.04         10.04  
2019-02-22       -6.15              0          -6.15         -6.15  
2019-02-27    -1120.16        1122.89           2.73          2.73  
2019-03-28       55.34              0          55.34         55.34  
2019-04-03    -1157.36        1210.81          53.45         53.45  
2019-05-02       15.24              0          15.24         15.24  
2019-06-18    -1096.26        1105.24           8.98          8.98  
2019-06-27       -9.51              0          -9.51         -9.51  
2019-07-03    -1128.01        1122.99          -5.02         -5.02  
2019-08-07       29.79              0          29.79         29.79  
2019-08-09     -1170.2         1188.9           18.7          18.7  
2019-08-13        4.15              0           4.15          4.15  
2019-08-14    -1171.92        1164.25          -7.67         -7.67  
2019-08-15       -3.49              0          -3.49         -3.49  
2019-08-20    -1198.84        1183.53         -15.31        -15.31  
2019-08-26      -39.39              0         -39.39        -39.39  
2019-08-30    -1239.74        1190.53         -49.21        -49.21  
2019-09-04      -60.29              0         -60.29        -60.29  
2019-09-05    -1253.95        1212.19         -41.76        -41.76  
2019-10-02      -57.45              0         -57.45        -57.45  
2019-10-15    -1278.95        1242.24         -36.71        -36.71  
2019-11-25       17.31              0          17.31         17.31  
2019-11-26     -1292.6           1313           20.4          20.4  
2019-12-03      -13.94              0         -13.94        -13.94  
2019-12-05    -1340.94        1326.96         -13.98        -13.98  
2020-01-02        7.47              0           7.47          7.47  
2020-01-03    -1340.53        1361.52          20.99         20.99  
2020-02-03      121.12              0         121.12        121.12  
2020-02-04    -1333.37        1445.41         112.04        112.04  
2020-02-06      118.61              0         118.61        118.61  
2020-02-07    -1348.77        1479.11         130.34        130.34  
2020-02-25       82.23              0          82.23         82.23  
2020-04-01    -1041.77         1102.1          60.33         60.33  
2020-04-02       58.23              0          58.23         58.23  
2020-04-07    -1158.78        1182.56          23.78         23.78  
2020-06-15      230.71              0         230.71        230.71  
2020-06-17    -1222.23        1452.54         230.31        230.31  
2020-06-29      138.11              0         138.11        138.11  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $138.11
The current status of the model is: Waiting to enter since 2020-06-29 00:00:00 

Processing portfolio for model: EMA_002_SlowMA_15_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-04-01 00:00:00 at the price of 1187.54
BOUGHT QTY: 1 on 2019-04-02 00:00:00 at the price of 1200.05
SOLD QTY: -1 on 2019-05-02 00:00:00 at the price of 1172.6
BOUGHT QTY: 1 on 2019-06-20 00:00:00 at the price of 1121.7
SOLD QTY: -1 on 2019-06-27 00:00:00 at the price of 1086.75
BOUGHT QTY: 1 on 2019-07-03 00:00:00 at the price of 1118.5
SOLD QTY: -1 on 2019-08-15 00:00:00 at the price of 1168.43
BOUGHT QTY: 1 on 2019-08-20 00:00:00 at the price of 1195.35
SOLD QTY: -1 on 2019-08-26 00:00:00 at the price of 1159.45
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-09-04 00:00:00 at the price of 1179.45
BOUGHT QTY: 1 on 2019-09-05 00:00:00 at the price of 1193.66
SOLD QTY: -1 on 2019-10-02 00:00:00 at the price of 1196.5
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2019-12-04 00:00:00 at the price of 1306.1
BOUGHT QTY: 1 on 2019-12-05 00:00:00 at the price of 1327.0
SOLD QTY: -1 on 2020-02-25 00:00:00 at the price of 1431.0
BOUGHT QTY: 1 on 2020-04-08 00:00:00 at the price of 1203.1
SOLD QTY: -1 on 2020-06-29 00:00:00 at the price of 1360.34
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-04-01           -1          0          0          1187.54    106.57   
2019-04-02            1          1    1200.05                0         0   
2019-05-02           -1          0          0           1172.6    -27.45   
2019-06-20            1          1     1121.7                0         0   
2019-06-27           -1          0          0          1086.75    -34.95   
2019-07-03            1          1     1118.5                0         0   
2019-08-15           -1          0          0          1168.43     49.93   
2019-08-20            1          1    1195.35                0         0   
2019-08-26           -1          0          0          1159.45     -35.9   
2019-08-30            1          1    1200.35                0         0   
2019-09-04           -1          0          0          1179.45     -20.9   
2019-09-05            1          1    1193.66                0         0   
2019-10-02           -1          0          0           1196.5      2.84   
2019-10-15            1          1     1221.5                0         0   
2019-12-04           -1          0          0           1306.1      84.6   
2019-12-05            1          1       1327                0         0   
2020-02-25           -1          0          0             1431       104   
2020-04-08            1          1     1203.1                0         0   
2020-06-29           -1          0          0          1360.34    157.24   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-04-01      106.57              0         106.57        106.57  
2019-04-02    -1093.48        1205.54         112.06        112.06  
2019-05-02       79.12              0          79.12         79.12  
2019-06-20    -1042.58         1113.2          70.62         70.62  
2019-06-27       44.17              0          44.17         44.17  
2019-07-03    -1074.33        1122.99          48.66         48.66  
2019-08-15        94.1              0           94.1          94.1  
2019-08-20    -1101.25        1183.53          82.28         82.28  
2019-08-26        58.2              0           58.2          58.2  
2019-08-30    -1142.15        1190.53          48.38         48.38  
2019-09-04        37.3              0           37.3          37.3  
2019-09-05    -1156.36        1212.19          55.83         55.83  
2019-10-02       40.14              0          40.14         40.14  
2019-10-15    -1181.36        1242.24          60.88         60.88  
2019-12-04      124.74              0         124.74        124.74  
2019-12-05    -1202.26        1326.96          124.7         124.7  
2020-02-25      228.74              0         228.74        228.74  
2020-04-08     -974.36           1207         232.64        232.64  
2020-06-29      385.98              0         385.98        385.98  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $385.98
The current status of the model is: Waiting to enter since 2020-06-29 00:00:00 

Processing portfolio for model: EMA_003_SlowMA_15_FastMA_10
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-05-03 00:00:00 at the price of 1177.41
BOUGHT QTY: 1 on 2019-06-24 00:00:00 at the price of 1120.0
SOLD QTY: -1 on 2019-06-26 00:00:00 at the price of 1091.0
BOUGHT QTY: 1 on 2019-07-05 00:00:00 at the price of 1119.37
SOLD QTY: -1 on 2019-08-26 00:00:00 at the price of 1159.45
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-09-04 00:00:00 at the price of 1179.45
BOUGHT QTY: 1 on 2019-09-05 00:00:00 at the price of 1193.66
SOLD QTY: -1 on 2019-10-03 00:00:00 at the price of 1183.34
BOUGHT QTY: 1 on 2019-10-16 00:00:00 at the price of 1241.81
SOLD QTY: -1 on 2020-02-26 00:00:00 at the price of 1394.98
BOUGHT QTY: 1 on 2020-04-13 00:00:00 at the price of 1201.5
SOLD QTY: -1 on 2020-06-29 00:00:00 at the price of 1360.34
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-03           -1          0          0          1177.41     96.44   
2019-06-24            1          1       1120                0         0   
2019-06-26           -1          0          0             1091       -29   
2019-07-05            1          1    1119.37                0         0   
2019-08-26           -1          0          0          1159.45     40.08   
2019-08-30            1          1    1200.35                0         0   
2019-09-04           -1          0          0          1179.45     -20.9   
2019-09-05            1          1    1193.66                0         0   
2019-10-03           -1          0          0          1183.34    -10.32   
2019-10-16            1          1    1241.81                0         0   
2020-02-26           -1          0          0          1394.98    153.17   
2020-04-13            1          1     1201.5                0         0   
2020-06-29           -1          0          0          1360.34    158.84   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-03       96.44              0          96.44         96.44  
2019-06-24    -1023.56         1116.7          93.14         93.14  
2019-06-26       67.44              0          67.44         67.44  
2019-07-05    -1051.93        1132.66          80.73         80.73  
2019-08-26      107.52              0         107.52        107.52  
2019-08-30    -1092.83        1190.53           97.7          97.7  
2019-09-04       86.62              0          86.62         86.62  
2019-09-05    -1107.04        1212.19         105.15        105.15  
2019-10-03        76.3              0           76.3          76.3  
2019-10-16    -1165.51           1243          77.49         77.49  
2020-02-26      229.47              0         229.47        229.47  
2020-04-13     -972.03        1210.41         238.38        238.38  
2020-06-29      388.31              0         388.31        388.31  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $388.31
The current status of the model is: Waiting to enter since 2020-06-29 00:00:00 

Processing portfolio for model: EMA_004_SlowMA_20_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-05-02 00:00:00 at the price of 1172.6
BOUGHT QTY: 1 on 2019-06-24 00:00:00 at the price of 1120.0
SOLD QTY: -1 on 2019-06-26 00:00:00 at the price of 1091.0
BOUGHT QTY: 1 on 2019-07-05 00:00:00 at the price of 1119.37
SOLD QTY: -1 on 2019-08-26 00:00:00 at the price of 1159.45
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-10-03 00:00:00 at the price of 1183.34
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2020-02-25 00:00:00 at the price of 1431.0
BOUGHT QTY: 1 on 2020-04-09 00:00:00 at the price of 1218.18
SOLD QTY: -1 on 2020-06-29 00:00:00 at the price of 1360.34
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-02           -1          0          0           1172.6     91.63   
2019-06-24            1          1       1120                0         0   
2019-06-26           -1          0          0             1091       -29   
2019-07-05            1          1    1119.37                0         0   
2019-08-26           -1          0          0          1159.45     40.08   
2019-08-30            1          1    1200.35                0         0   
2019-10-03           -1          0          0          1183.34    -17.01   
2019-10-15            1          1     1221.5                0         0   
2020-02-25           -1          0          0             1431     209.5   
2020-04-09            1          1    1218.18                0         0   
2020-06-29           -1          0          0          1360.34    142.16   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-02       91.63              0          91.63         91.63  
2019-06-24    -1028.37         1116.7          88.33         88.33  
2019-06-26       62.63              0          62.63         62.63  
2019-07-05    -1056.74        1132.66          75.92         75.92  
2019-08-26      102.71              0         102.71        102.71  
2019-08-30    -1097.64        1190.53          92.89         92.89  
2019-10-03        85.7              0           85.7          85.7  
2019-10-15     -1135.8        1242.24         106.44        106.44  
2020-02-25       295.2              0          295.2         295.2  
2020-04-09     -922.98        1206.57         283.59        283.59  
2020-06-29      437.36              0         437.36        437.36  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $437.36
The current status of the model is: Waiting to enter since 2020-06-29 00:00:00 

Processing portfolio for model: EMA_005_SlowMA_20_FastMA_10
BOUGHT QTY: 1 on 2019-01-08 00:00:00 at the price of 1086.0
SOLD QTY: -1 on 2019-05-03 00:00:00 at the price of 1177.41
BOUGHT QTY: 1 on 2019-07-08 00:00:00 at the price of 1125.87
SOLD QTY: -1 on 2019-08-29 00:00:00 at the price of 1186.42
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-10-04 00:00:00 at the price of 1194.29
BOUGHT QTY: 1 on 2019-10-16 00:00:00 at the price of 1241.81
SOLD QTY: -1 on 2020-02-26 00:00:00 at the price of 1394.98
BOUGHT QTY: 1 on 2020-04-15 00:00:00 at the price of 1246.51
SOLD QTY: -1 on 2020-06-30 00:00:00 at the price of 1396.88
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-08            1          1       1086                0         0   
2019-05-03           -1          0          0          1177.41     91.41   
2019-07-08            1          1    1125.87                0         0   
2019-08-29           -1          0          0          1186.42     60.55   
2019-08-30            1          1    1200.35                0         0   
2019-10-04           -1          0          0          1194.29     -6.06   
2019-10-16            1          1    1241.81                0         0   
2020-02-26           -1          0          0          1394.98    153.17   
2020-04-15            1          1    1246.51                0         0   
2020-06-30           -1          0          0          1396.88    150.37   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-08       -1086        1085.37          -0.63         -0.63  
2019-05-03       91.41              0          91.41         91.41  
2019-07-08    -1034.46        1116.79          82.33         82.33  
2019-08-29      151.96              0         151.96        151.96  
2019-08-30    -1048.39        1190.53         142.14        142.14  
2019-10-04       145.9              0          145.9         145.9  
2019-10-16    -1095.91           1243         147.09        147.09  
2020-02-26      299.07              0         299.07        299.07  
2020-04-15     -947.44         1257.3         309.86        309.86  
2020-06-30      449.44              0         449.44        449.44  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $449.44
The current status of the model is: Waiting to enter since 2020-06-30 00:00:00 

Processing portfolio for model: EMA_006_SlowMA_20_FastMA_15
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-07 00:00:00 at the price of 1185.81
BOUGHT QTY: 1 on 2019-07-10 00:00:00 at the price of 1132.32
SOLD QTY: -1 on 2019-10-09 00:00:00 at the price of 1201.33
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-17 00:00:00 at the price of 1281.7
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-07           -1          0          0          1185.81     97.82   
2019-07-10            1          1    1132.32                0         0   
2019-10-09           -1          0          0          1201.33     69.01   
2019-10-15            1          1     1221.5                0         0   
2020-02-27           -1          0          0          1359.14    137.64   
2020-04-17            1          1     1281.7                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-07       97.82              0          97.82         97.82  
2019-07-10     -1034.5        1140.91         106.41        106.41  
2019-10-09      166.83              0         166.83        166.83  
2019-10-15    -1054.67        1242.24         187.57        187.57  
2020-02-27      304.47              0         304.47        304.47  
2020-04-17     -977.23           1279         301.77        301.77  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $464.77
The current status of the model is: Holding a position since 2020-04-17 00:00:00 

Processing portfolio for model: EMA_007_SlowMA_25_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-05-02 00:00:00 at the price of 1172.6
BOUGHT QTY: 1 on 2019-06-25 00:00:00 at the price of 1115.08
SOLD QTY: -1 on 2019-06-26 00:00:00 at the price of 1091.0
BOUGHT QTY: 1 on 2019-07-05 00:00:00 at the price of 1119.37
SOLD QTY: -1 on 2019-08-27 00:00:00 at the price of 1183.0
BOUGHT QTY: 1 on 2019-08-30 00:00:00 at the price of 1200.35
SOLD QTY: -1 on 2019-10-03 00:00:00 at the price of 1183.34
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2020-02-26 00:00:00 at the price of 1394.98
BOUGHT QTY: 1 on 2020-04-14 00:00:00 at the price of 1239.97
SOLD QTY: -1 on 2020-06-29 00:00:00 at the price of 1360.34
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-02           -1          0          0           1172.6     91.63   
2019-06-25            1          1    1115.08                0         0   
2019-06-26           -1          0          0             1091    -24.08   
2019-07-05            1          1    1119.37                0         0   
2019-08-27           -1          0          0             1183     63.63   
2019-08-30            1          1    1200.35                0         0   
2019-10-03           -1          0          0          1183.34    -17.01   
2019-10-15            1          1     1221.5                0         0   
2020-02-26           -1          0          0          1394.98    173.48   
2020-04-14            1          1    1239.97                0         0   
2020-06-29           -1          0          0          1360.34    120.37   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-02       91.63              0          91.63         91.63  
2019-06-25    -1023.45        1087.58          64.13         64.13  
2019-06-26       67.55              0          67.55         67.55  
2019-07-05    -1051.82        1132.66          80.84         80.84  
2019-08-27      131.18              0         131.18        131.18  
2019-08-30    -1069.17        1190.53         121.36        121.36  
2019-10-03      114.17              0         114.17        114.17  
2019-10-15    -1107.33        1242.24         134.91        134.91  
2020-02-26      287.65              0         287.65        287.65  
2020-04-14     -952.32        1265.23         312.91        312.91  
2020-06-29      408.02              0         408.02        408.02  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $408.02
The current status of the model is: Waiting to enter since 2020-06-29 00:00:00 

Processing portfolio for model: EMA_008_SlowMA_25_FastMA_10
BOUGHT QTY: 1 on 2019-01-08 00:00:00 at the price of 1086.0
SOLD QTY: -1 on 2019-05-06 00:00:00 at the price of 1172.0
BOUGHT QTY: 1 on 2019-07-09 00:00:00 at the price of 1110.32
SOLD QTY: -1 on 2019-10-08 00:00:00 at the price of 1198.77
BOUGHT QTY: 1 on 2019-10-15 00:00:00 at the price of 1221.5
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-16 00:00:00 at the price of 1267.14
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-08            1          1       1086                0         0   
2019-05-06           -1          0          0             1172        86   
2019-07-09            1          1    1110.32                0         0   
2019-10-08           -1          0          0          1198.77     88.45   
2019-10-15            1          1     1221.5                0         0   
2020-02-27           -1          0          0          1359.14    137.64   
2020-04-16            1          1    1267.14                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-08       -1086        1085.37          -0.63         -0.63  
2019-05-06          86              0             86            86  
2019-07-09    -1024.32        1124.29          99.97         99.97  
2019-10-08      174.45              0         174.45        174.45  
2019-10-15    -1047.05        1242.24         195.19        195.19  
2020-02-27      312.09              0         312.09        312.09  
2020-04-16     -955.05        1257.43         302.38        302.38  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $486.95
The current status of the model is: Holding a position since 2020-04-16 00:00:00 

Processing portfolio for model: EMA_009_SlowMA_25_FastMA_15
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-08 00:00:00 at the price of 1177.29
BOUGHT QTY: 1 on 2019-07-11 00:00:00 at the price of 1146.16
SOLD QTY: -1 on 2020-02-28 00:00:00 at the price of 1274.31
BOUGHT QTY: 1 on 2020-04-20 00:00:00 at the price of 1269.89
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-08           -1          0          0          1177.29      89.3   
2019-07-11            1          1    1146.16                0         0   
2020-02-28           -1          0          0          1274.31    128.15   
2020-04-20            1          1    1269.89                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-08        89.3              0           89.3          89.3  
2019-07-11    -1056.86        1144.08          87.22         87.22  
2020-02-28      217.45              0         217.45        217.45  
2020-04-20    -1052.44        1261.15         208.71        208.71  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $389.56
The current status of the model is: Holding a position since 2020-04-20 00:00:00 

Processing portfolio for model: EMA_010_SlowMA_25_FastMA_20
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-10 00:00:00 at the price of 1168.84
BOUGHT QTY: 1 on 2019-07-15 00:00:00 at the price of 1145.34
SOLD QTY: -1 on 2020-03-02 00:00:00 at the price of 1351.39
BOUGHT QTY: 1 on 2020-04-24 00:00:00 at the price of 1255.0
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-10           -1          0          0          1168.84      93.9   
2019-07-15            1          1    1145.34                0         0   
2020-03-02           -1          0          0          1351.39    206.05   
2020-04-24            1          1       1255                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-10        93.9              0           93.9          93.9  
2019-07-15    -1051.44        1150.51          99.07         99.07  
2020-03-02      299.95              0         299.95        299.95  
2020-04-24     -955.05         1276.6         321.55        321.55  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $486.95
The current status of the model is: Holding a position since 2020-04-24 00:00:00 

Processing portfolio for model: EMA_011_SlowMA_30_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-05-03 00:00:00 at the price of 1177.41
BOUGHT QTY: 1 on 2019-07-08 00:00:00 at the price of 1125.87
SOLD QTY: -1 on 2019-10-03 00:00:00 at the price of 1183.34
BOUGHT QTY: 1 on 2019-10-14 00:00:00 at the price of 1213.89
SOLD QTY: -1 on 2020-02-26 00:00:00 at the price of 1394.98
BOUGHT QTY: 1 on 2020-04-15 00:00:00 at the price of 1246.51
SOLD QTY: -1 on 2020-06-30 00:00:00 at the price of 1396.88
BOUGHT QTY: 1 on 2020-07-01 00:00:00 at the price of 1419.17
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-03           -1          0          0          1177.41     96.44   
2019-07-08            1          1    1125.87                0         0   
2019-10-03           -1          0          0          1183.34     57.47   
2019-10-14            1          1    1213.89                0         0   
2020-02-26           -1          0          0          1394.98    181.09   
2020-04-15            1          1    1246.51                0         0   
2020-06-30           -1          0          0          1396.88    150.37   
2020-07-01            1          1    1419.17                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-03       96.44              0          96.44         96.44  
2019-07-08    -1029.43        1116.79          87.36         87.36  
2019-10-03      153.91              0         153.91        153.91  
2019-10-14    -1059.98        1217.77         157.79        157.79  
2020-02-26         335              0            335           335  
2020-04-15     -911.51         1257.3         345.79        345.79  
2020-06-30      485.37              0         485.37        485.37  
2020-07-01      -933.8           1442          508.2         508.2  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $508.20
The current status of the model is: Holding a position since 2020-07-01 00:00:00 

Processing portfolio for model: EMA_012_SlowMA_30_FastMA_10
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-07 00:00:00 at the price of 1185.81
BOUGHT QTY: 1 on 2019-07-11 00:00:00 at the price of 1146.16
SOLD QTY: -1 on 2019-10-09 00:00:00 at the price of 1201.33
BOUGHT QTY: 1 on 2019-10-14 00:00:00 at the price of 1213.89
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-17 00:00:00 at the price of 1281.7
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-07           -1          0          0          1185.81     97.82   
2019-07-11            1          1    1146.16                0         0   
2019-10-09           -1          0          0          1201.33     55.17   
2019-10-14            1          1    1213.89                0         0   
2020-02-27           -1          0          0          1359.14    145.25   
2020-04-17            1          1     1281.7                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-07       97.82              0          97.82         97.82  
2019-07-11    -1048.34        1144.08          95.74         95.74  
2019-10-09      152.99              0         152.99        152.99  
2019-10-14     -1060.9        1217.77         156.87        156.87  
2020-02-27      298.24              0         298.24        298.24  
2020-04-17     -983.46           1279         295.54        295.54  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $458.54
The current status of the model is: Holding a position since 2020-04-17 00:00:00 

Processing portfolio for model: EMA_013_SlowMA_30_FastMA_15
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-09 00:00:00 at the price of 1162.6
BOUGHT QTY: 1 on 2019-07-12 00:00:00 at the price of 1142.93
SOLD QTY: -1 on 2020-02-28 00:00:00 at the price of 1274.31
BOUGHT QTY: 1 on 2020-04-24 00:00:00 at the price of 1255.0
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-09           -1          0          0           1162.6     87.66   
2019-07-12            1          1    1142.93                0         0   
2020-02-28           -1          0          0          1274.31    131.38   
2020-04-24            1          1       1255                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-09       87.66              0          87.66         87.66  
2019-07-12    -1055.27        1145.34          90.07         90.07  
2020-02-28      219.04              0         219.04        219.04  
2020-04-24    -1035.96         1276.6         240.64        240.64  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $406.04
The current status of the model is: Holding a position since 2020-04-24 00:00:00 

Processing portfolio for model: EMA_014_SlowMA_30_FastMA_20
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-13 00:00:00 at the price of 1145.24
BOUGHT QTY: 1 on 2019-07-16 00:00:00 at the price of 1146.73
SOLD QTY: -1 on 2020-03-02 00:00:00 at the price of 1351.39
BOUGHT QTY: 1 on 2020-04-28 00:00:00 at the price of 1283.2
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-13           -1          0          0          1145.24      70.3   
2019-07-16            1          1    1146.73                0         0   
2020-03-02           -1          0          0          1351.39    204.66   
2020-04-28            1          1     1283.2                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-13        70.3              0           70.3          70.3  
2019-07-16    -1076.43        1153.46          77.03         77.03  
2020-03-02      274.96              0         274.96        274.96  
2020-04-28    -1008.24        1232.59         224.35        224.35  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $433.76
The current status of the model is: Holding a position since 2020-04-28 00:00:00 

Processing portfolio for model: EMA_015_SlowMA_35_FastMA_05
BOUGHT QTY: 1 on 2019-01-07 00:00:00 at the price of 1080.97
SOLD QTY: -1 on 2019-05-03 00:00:00 at the price of 1177.41
BOUGHT QTY: 1 on 2019-07-08 00:00:00 at the price of 1125.87
SOLD QTY: -1 on 2019-10-04 00:00:00 at the price of 1194.29
BOUGHT QTY: 1 on 2019-10-14 00:00:00 at the price of 1213.89
SOLD QTY: -1 on 2020-02-26 00:00:00 at the price of 1394.98
BOUGHT QTY: 1 on 2020-04-15 00:00:00 at the price of 1246.51
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-03           -1          0          0          1177.41     96.44   
2019-07-08            1          1    1125.87                0         0   
2019-10-04           -1          0          0          1194.29     68.42   
2019-10-14            1          1    1213.89                0         0   
2020-02-26           -1          0          0          1394.98    181.09   
2020-04-15            1          1    1246.51                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-03       96.44              0          96.44         96.44  
2019-07-08    -1029.43        1116.79          87.36         87.36  
2019-10-04      164.86              0         164.86        164.86  
2019-10-14    -1049.03        1217.77         168.74        168.74  
2020-02-26      345.95              0         345.95        345.95  
2020-04-15     -900.56         1257.3         356.74        356.74  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $541.44
The current status of the model is: Holding a position since 2020-04-15 00:00:00 

Processing portfolio for model: EMA_016_SlowMA_35_FastMA_10
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-08 00:00:00 at the price of 1177.29
BOUGHT QTY: 1 on 2019-07-11 00:00:00 at the price of 1146.16
SOLD QTY: -1 on 2020-02-28 00:00:00 at the price of 1274.31
BOUGHT QTY: 1 on 2020-04-20 00:00:00 at the price of 1269.89
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-08           -1          0          0          1177.29      89.3   
2019-07-11            1          1    1146.16                0         0   
2020-02-28           -1          0          0          1274.31    128.15   
2020-04-20            1          1    1269.89                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-08        89.3              0           89.3          89.3  
2019-07-11    -1056.86        1144.08          87.22         87.22  
2020-02-28      217.45              0         217.45        217.45  
2020-04-20    -1052.44        1261.15         208.71        208.71  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $389.56
The current status of the model is: Holding a position since 2020-04-20 00:00:00 

Processing portfolio for model: EMA_017_SlowMA_35_FastMA_15
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-10 00:00:00 at the price of 1168.84
BOUGHT QTY: 1 on 2019-07-15 00:00:00 at the price of 1145.34
SOLD QTY: -1 on 2020-03-02 00:00:00 at the price of 1351.39
BOUGHT QTY: 1 on 2020-04-27 00:00:00 at the price of 1292.0
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-10           -1          0          0          1168.84      93.9   
2019-07-15            1          1    1145.34                0         0   
2020-03-02           -1          0          0          1351.39    206.05   
2020-04-27            1          1       1292                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-10        93.9              0           93.9          93.9  
2019-07-15    -1051.44        1150.51          99.07         99.07  
2020-03-02      299.95              0         299.95        299.95  
2020-04-27     -992.05        1270.86         278.81        278.81  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $449.95
The current status of the model is: Holding a position since 2020-04-27 00:00:00 

Processing portfolio for model: EMA_018_SlowMA_35_FastMA_20
BOUGHT QTY: 1 on 2019-01-11 00:00:00 at the price of 1069.9
SOLD QTY: -1 on 2019-05-14 00:00:00 at the price of 1142.32
BOUGHT QTY: 1 on 2019-07-17 00:00:00 at the price of 1150.92
SOLD QTY: -1 on 2020-03-04 00:00:00 at the price of 1358.96
BOUGHT QTY: 1 on 2020-04-30 00:00:00 at the price of 1331.36
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-11            1          1     1069.9                0         0   
2019-05-14           -1          0          0          1142.32     72.42   
2019-07-17            1          1    1150.92                0         0   
2020-03-04           -1          0          0          1358.96    208.04   
2020-04-30            1          1    1331.36                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-11     -1069.9        1064.47          -5.43         -5.43  
2019-05-14       72.42              0          72.42         72.42  
2019-07-17     -1078.5        1146.74          68.24         68.24  
2020-03-04      280.46              0         280.46        280.46  
2020-04-30     -1050.9         1346.7          295.8         295.8  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $391.10
The current status of the model is: Holding a position since 2020-04-30 00:00:00 

Processing portfolio for model: EMA_019_SlowMA_40_FastMA_05
BOUGHT QTY: 1 on 2019-01-08 00:00:00 at the price of 1086.0
SOLD QTY: -1 on 2019-05-03 00:00:00 at the price of 1177.41
BOUGHT QTY: 1 on 2019-07-10 00:00:00 at the price of 1132.32
SOLD QTY: -1 on 2019-10-04 00:00:00 at the price of 1194.29
BOUGHT QTY: 1 on 2019-10-07 00:00:00 at the price of 1207.0
SOLD QTY: -1 on 2019-10-09 00:00:00 at the price of 1201.33
BOUGHT QTY: 1 on 2019-10-11 00:00:00 at the price of 1224.03
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-16 00:00:00 at the price of 1267.14
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-08            1          1       1086                0         0   
2019-05-03           -1          0          0          1177.41     91.41   
2019-07-10            1          1    1132.32                0         0   
2019-10-04           -1          0          0          1194.29     61.97   
2019-10-07            1          1       1207                0         0   
2019-10-09           -1          0          0          1201.33     -5.67   
2019-10-11            1          1    1224.03                0         0   
2020-02-27           -1          0          0          1359.14    135.11   
2020-04-16            1          1    1267.14                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-08       -1086        1085.37          -0.63         -0.63  
2019-05-03       91.41              0          91.41         91.41  
2019-07-10    -1040.91        1140.91            100           100  
2019-10-04      153.38              0         153.38        153.38  
2019-10-07    -1053.62        1208.25         154.63        154.63  
2019-10-09      147.71              0         147.71        147.71  
2019-10-11    -1076.32        1215.71         139.39        139.39  
2020-02-27      282.82              0         282.82        282.82  
2020-04-16     -984.32        1257.43         273.11        273.11  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $457.68
The current status of the model is: Holding a position since 2020-04-16 00:00:00 

Processing portfolio for model: EMA_020_SlowMA_40_FastMA_10
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-09 00:00:00 at the price of 1162.6
BOUGHT QTY: 1 on 2019-07-12 00:00:00 at the price of 1142.93
SOLD QTY: -1 on 2020-02-28 00:00:00 at the price of 1274.31
BOUGHT QTY: 1 on 2020-04-24 00:00:00 at the price of 1255.0
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-09           -1          0          0           1162.6     74.61   
2019-07-12            1          1    1142.93                0         0   
2020-02-28           -1          0          0          1274.31    131.38   
2020-04-24            1          1       1255                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-09       74.61              0          74.61         74.61  
2019-07-12    -1068.32        1145.34          77.02         77.02  
2020-02-28      205.99              0         205.99        205.99  
2020-04-24    -1049.01         1276.6         227.59        227.59  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $392.99
The current status of the model is: Holding a position since 2020-04-24 00:00:00 

Processing portfolio for model: EMA_021_SlowMA_40_FastMA_15
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-13 00:00:00 at the price of 1145.24
BOUGHT QTY: 1 on 2019-07-16 00:00:00 at the price of 1146.73
SOLD QTY: -1 on 2020-03-02 00:00:00 at the price of 1351.39
BOUGHT QTY: 1 on 2020-04-30 00:00:00 at the price of 1331.36
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-13           -1          0          0          1145.24      70.3   
2019-07-16            1          1    1146.73                0         0   
2020-03-02           -1          0          0          1351.39    204.66   
2020-04-30            1          1    1331.36                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-13        70.3              0           70.3          70.3  
2019-07-16    -1076.43        1153.46          77.03         77.03  
2020-03-02      274.96              0         274.96        274.96  
2020-04-30     -1056.4         1346.7          290.3         290.3  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $385.60
The current status of the model is: Holding a position since 2020-04-30 00:00:00 

Processing portfolio for model: EMA_022_SlowMA_40_FastMA_20
BOUGHT QTY: 1 on 2019-01-11 00:00:00 at the price of 1069.9
SOLD QTY: -1 on 2019-05-15 00:00:00 at the price of 1122.55
BOUGHT QTY: 1 on 2019-07-18 00:00:00 at the price of 1142.0
SOLD QTY: -1 on 2020-03-04 00:00:00 at the price of 1358.96
BOUGHT QTY: 1 on 2020-05-01 00:00:00 at the price of 1324.09
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-11            1          1     1069.9                0         0   
2019-05-15           -1          0          0          1122.55     52.65   
2019-07-18            1          1       1142                0         0   
2020-03-04           -1          0          0          1358.96    216.96   
2020-05-01            1          1    1324.09                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-11     -1069.9        1064.47          -5.43         -5.43  
2019-05-15       52.65              0          52.65         52.65  
2019-07-18    -1089.35        1147.24          57.89         57.89  
2020-03-04      269.61              0         269.61        269.61  
2020-05-01    -1054.48        1317.32         262.84        262.84  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $387.52
The current status of the model is: Holding a position since 2020-05-01 00:00:00 

Processing portfolio for model: EMA_023_SlowMA_45_FastMA_05
BOUGHT QTY: 1 on 2019-01-08 00:00:00 at the price of 1086.0
SOLD QTY: -1 on 2019-05-06 00:00:00 at the price of 1172.0
BOUGHT QTY: 1 on 2019-07-11 00:00:00 at the price of 1146.16
SOLD QTY: -1 on 2019-10-09 00:00:00 at the price of 1201.33
BOUGHT QTY: 1 on 2019-10-10 00:00:00 at the price of 1198.6
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-17 00:00:00 at the price of 1281.7
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-08            1          1       1086                0         0   
2019-05-06           -1          0          0             1172        86   
2019-07-11            1          1    1146.16                0         0   
2019-10-09           -1          0          0          1201.33     55.17   
2019-10-10            1          1     1198.6                0         0   
2020-02-27           -1          0          0          1359.14    160.54   
2020-04-17            1          1     1281.7                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-08       -1086        1085.37          -0.63         -0.63  
2019-05-06          86              0             86            86  
2019-07-11    -1060.16        1144.08          83.92         83.92  
2019-10-09      141.17              0         141.17        141.17  
2019-10-10    -1057.43        1209.47         152.04        152.04  
2020-02-27      301.71              0         301.71        301.71  
2020-04-17     -979.99           1279         299.01        299.01  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $462.01
The current status of the model is: Holding a position since 2020-04-17 00:00:00 

Processing portfolio for model: EMA_024_SlowMA_45_FastMA_10
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-10 00:00:00 at the price of 1168.84
BOUGHT QTY: 1 on 2019-07-15 00:00:00 at the price of 1145.34
SOLD QTY: -1 on 2020-02-28 00:00:00 at the price of 1274.31
BOUGHT QTY: 1 on 2020-04-27 00:00:00 at the price of 1292.0
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-10           -1          0          0          1168.84     80.85   
2019-07-15            1          1    1145.34                0         0   
2020-02-28           -1          0          0          1274.31    128.97   
2020-04-27            1          1       1292                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-10       80.85              0          80.85         80.85  
2019-07-15    -1064.49        1150.51          86.02         86.02  
2020-02-28      209.82              0         209.82        209.82  
2020-04-27    -1082.18        1270.86         188.68        188.68  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $359.82
The current status of the model is: Holding a position since 2020-04-27 00:00:00 

Processing portfolio for model: EMA_025_SlowMA_45_FastMA_15
BOUGHT QTY: 1 on 2019-01-10 00:00:00 at the price of 1074.94
SOLD QTY: -1 on 2019-05-14 00:00:00 at the price of 1142.32
BOUGHT QTY: 1 on 2019-07-17 00:00:00 at the price of 1150.92
SOLD QTY: -1 on 2020-03-03 00:00:00 at the price of 1397.68
BOUGHT QTY: 1 on 2020-04-30 00:00:00 at the price of 1331.36
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-10            1          1    1074.94                0         0   
2019-05-14           -1          0          0          1142.32     67.38   
2019-07-17            1          1    1150.92                0         0   
2020-03-03           -1          0          0          1397.68    246.76   
2020-04-30            1          1    1331.36                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-10    -1074.94        1078.83           3.89          3.89  
2019-05-14       67.38              0          67.38         67.38  
2019-07-17    -1083.54        1146.74           63.2          63.2  
2020-03-03      314.14              0         314.14        314.14  
2020-04-30    -1017.22         1346.7         329.48        329.48  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $424.78
The current status of the model is: Holding a position since 2020-04-30 00:00:00 

Processing portfolio for model: EMA_026_SlowMA_45_FastMA_20
BOUGHT QTY: 1 on 2019-01-11 00:00:00 at the price of 1069.9
SOLD QTY: -1 on 2019-01-15 00:00:00 at the price of 1058.01
BOUGHT QTY: 1 on 2019-01-16 00:00:00 at the price of 1090.0
SOLD QTY: -1 on 2019-05-15 00:00:00 at the price of 1122.55
BOUGHT QTY: 1 on 2019-07-19 00:00:00 at the price of 1149.32
SOLD QTY: -1 on 2020-03-06 00:00:00 at the price of 1269.95
BOUGHT QTY: 1 on 2020-05-04 00:00:00 at the price of 1308.13
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-11            1          1     1069.9                0         0   
2019-01-15           -1          0          0          1058.01    -11.89   
2019-01-16            1          1       1090                0         0   
2019-05-15           -1          0          0          1122.55     32.55   
2019-07-19            1          1    1149.32                0         0   
2020-03-06           -1          0          0          1269.95    120.63   
2020-05-04            1          1    1308.13                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-11     -1069.9        1064.47          -5.43         -5.43  
2019-01-15      -11.89              0         -11.89        -11.89  
2019-01-16    -1101.89        1089.51         -12.38        -12.38  
2019-05-15       20.66              0          20.66         20.66  
2019-07-19    -1128.66        1131.55           2.89          2.89  
2020-03-06      141.29              0         141.29        141.29  
2020-05-04    -1166.84         1322.9         156.06        156.06  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $275.16
The current status of the model is: Holding a position since 2020-05-04 00:00:00 

Processing portfolio for model: EMA_027_SlowMA_50_FastMA_05
BOUGHT QTY: 1 on 2019-01-08 00:00:00 at the price of 1086.0
SOLD QTY: -1 on 2019-05-08 00:00:00 at the price of 1177.29
BOUGHT QTY: 1 on 2019-07-11 00:00:00 at the price of 1146.16
SOLD QTY: -1 on 2020-02-27 00:00:00 at the price of 1359.14
BOUGHT QTY: 1 on 2020-04-20 00:00:00 at the price of 1269.89
SOLD QTY: -1 on 2020-04-22 00:00:00 at the price of 1241.11
BOUGHT QTY: 1 on 2020-04-23 00:00:00 at the price of 1265.74
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-08            1          1       1086                0         0   
2019-05-08           -1          0          0          1177.29     91.29   
2019-07-11            1          1    1146.16                0         0   
2020-02-27           -1          0          0          1359.14    212.98   
2020-04-20            1          1    1269.89                0         0   
2020-04-22           -1          0          0          1241.11    -28.78   
2020-04-23            1          1    1265.74                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-08       -1086        1085.37          -0.63         -0.63  
2019-05-08       91.29              0          91.29         91.29  
2019-07-11    -1054.87        1144.08          89.21         89.21  
2020-02-27      304.27              0         304.27        304.27  
2020-04-20     -965.62        1261.15         295.53        295.53  
2020-04-22      275.49              0         275.49        275.49  
2020-04-23     -990.25        1271.17         280.92        280.92  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $451.75
The current status of the model is: Holding a position since 2020-04-23 00:00:00 

Processing portfolio for model: EMA_028_SlowMA_50_FastMA_10
BOUGHT QTY: 1 on 2019-01-09 00:00:00 at the price of 1087.99
SOLD QTY: -1 on 2019-05-13 00:00:00 at the price of 1145.24
BOUGHT QTY: 1 on 2019-07-15 00:00:00 at the price of 1145.34
SOLD QTY: -1 on 2020-03-02 00:00:00 at the price of 1351.39
BOUGHT QTY: 1 on 2020-04-28 00:00:00 at the price of 1283.2
SOLD QTY: -1 on 2020-04-29 00:00:00 at the price of 1345.0
BOUGHT QTY: 1 on 2020-04-30 00:00:00 at the price of 1331.36
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-09            1          1    1087.99                0         0   
2019-05-13           -1          0          0          1145.24     57.25   
2019-07-15            1          1    1145.34                0         0   
2020-03-02           -1          0          0          1351.39    206.05   
2020-04-28            1          1     1283.2                0         0   
2020-04-29           -1          0          0             1345      61.8   
2020-04-30            1          1    1331.36                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-09    -1087.99        1081.65          -6.34         -6.34  
2019-05-13       57.25              0          57.25         57.25  
2019-07-15    -1088.09        1150.51          62.42         62.42  
2020-03-02       263.3              0          263.3         263.3  
2020-04-28     -1019.9        1232.59         212.69        212.69  
2020-04-29       325.1              0          325.1         325.1  
2020-04-30    -1006.26         1346.7         340.44        340.44  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $435.74
The current status of the model is: Holding a position since 2020-04-30 00:00:00 

Processing portfolio for model: EMA_029_SlowMA_50_FastMA_15
BOUGHT QTY: 1 on 2019-01-11 00:00:00 at the price of 1069.9
SOLD QTY: -1 on 2019-05-14 00:00:00 at the price of 1142.32
BOUGHT QTY: 1 on 2019-07-17 00:00:00 at the price of 1150.92
SOLD QTY: -1 on 2020-03-04 00:00:00 at the price of 1358.96
BOUGHT QTY: 1 on 2020-05-01 00:00:00 at the price of 1324.09
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-11            1          1     1069.9                0         0   
2019-05-14           -1          0          0          1142.32     72.42   
2019-07-17            1          1    1150.92                0         0   
2020-03-04           -1          0          0          1358.96    208.04   
2020-05-01            1          1    1324.09                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-11     -1069.9        1064.47          -5.43         -5.43  
2019-05-14       72.42              0          72.42         72.42  
2019-07-17     -1078.5        1146.74          68.24         68.24  
2020-03-04      280.46              0         280.46        280.46  
2020-05-01    -1043.63        1317.32         273.69        273.69  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $398.37
The current status of the model is: Holding a position since 2020-05-01 00:00:00 

Processing portfolio for model: EMA_030_SlowMA_50_FastMA_20
BOUGHT QTY: 1 on 2019-01-14 00:00:00 at the price of 1053.34
SOLD QTY: -1 on 2019-01-15 00:00:00 at the price of 1058.01
BOUGHT QTY: 1 on 2019-01-16 00:00:00 at the price of 1090.0
SOLD QTY: -1 on 2019-05-17 00:00:00 at the price of 1175.83
BOUGHT QTY: 1 on 2019-07-24 00:00:00 at the price of 1132.62
SOLD QTY: -1 on 2020-03-06 00:00:00 at the price of 1269.95
BOUGHT QTY: 1 on 2020-05-05 00:00:00 at the price of 1337.5
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-14            1          1    1053.34                0         0   
2019-01-15           -1          0          0          1058.01      4.67   
2019-01-16            1          1       1090                0         0   
2019-05-17           -1          0          0          1175.83     85.83   
2019-07-24            1          1    1132.62                0         0   
2020-03-06           -1          0          0          1269.95    137.33   
2020-05-05            1          1     1337.5                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-14    -1053.34        1051.51          -1.83         -1.83  
2019-01-15        4.67              0           4.67          4.67  
2019-01-16    -1085.33        1089.51           4.18          4.18  
2019-05-17        90.5              0           90.5          90.5  
2019-07-24    -1042.12        1139.73          97.61         97.61  
2020-03-06      227.83              0         227.83        227.83  
2020-05-05    -1109.67        1349.02         239.35        239.35  
Accumulated profit/loss for one share of stock with initial capital of $0 at the end of modeling period: $332.33
The current status of the model is: Holding a position since 2020-05-05 00:00:00 

In [18]:
# Display the model performance summary
performance_summary.sort_values(by=['return_value'], inplace=True, ascending=False)
print(performance_summary)
                     model_name  return_value return_percent
14  EMA_015_SlowMA_35_FastMA_05        541.44           None
10  EMA_011_SlowMA_30_FastMA_05        508.20           None
7   EMA_008_SlowMA_25_FastMA_10        486.95           None
9   EMA_010_SlowMA_25_FastMA_20        486.95           None
5   EMA_006_SlowMA_20_FastMA_15        464.77           None
22  EMA_023_SlowMA_45_FastMA_05        462.01           None
11  EMA_012_SlowMA_30_FastMA_10        458.54           None
18  EMA_019_SlowMA_40_FastMA_05        457.68           None
26  EMA_027_SlowMA_50_FastMA_05        451.75           None
16  EMA_017_SlowMA_35_FastMA_15        449.95           None
4   EMA_005_SlowMA_20_FastMA_10        449.44           None
3   EMA_004_SlowMA_20_FastMA_05        437.36           None
27  EMA_028_SlowMA_50_FastMA_10        435.74           None
13  EMA_014_SlowMA_30_FastMA_20        433.76           None
24  EMA_025_SlowMA_45_FastMA_15        424.78           None
6   EMA_007_SlowMA_25_FastMA_05        408.02           None
12  EMA_013_SlowMA_30_FastMA_15        406.04           None
28  EMA_029_SlowMA_50_FastMA_15        398.37           None
19  EMA_020_SlowMA_40_FastMA_10        392.99           None
17  EMA_018_SlowMA_35_FastMA_20        391.10           None
8   EMA_009_SlowMA_25_FastMA_15        389.56           None
15  EMA_016_SlowMA_35_FastMA_10        389.56           None
2   EMA_003_SlowMA_15_FastMA_10        388.31           None
21  EMA_022_SlowMA_40_FastMA_20        387.52           None
1   EMA_002_SlowMA_15_FastMA_05        385.98           None
20  EMA_021_SlowMA_40_FastMA_15        385.60           None
23  EMA_024_SlowMA_45_FastMA_10        359.82           None
29  EMA_030_SlowMA_50_FastMA_20        332.33           None
25  EMA_026_SlowMA_45_FastMA_20        275.16           None
0   EMA_001_SlowMA_10_FastMA_05        138.11           None
In [19]:
# Display the transactions from the top model
top_model = performance_summary.iloc[0]['model_name']
print('The transactions from the top model %s:' % (top_model))
print(portfolio_collection[top_model][portfolio_collection[top_model].trade_action != 0])
The transactions from the top model EMA_015_SlowMA_35_FastMA_05:
           trade_action qty_onhand cost_basis sold_transaction gain_loss  \
date                                                                       
2019-01-07            1          1    1080.97                0         0   
2019-05-03           -1          0          0          1177.41     96.44   
2019-07-08            1          1    1125.87                0         0   
2019-10-04           -1          0          0          1194.29     68.42   
2019-10-14            1          1    1213.89                0         0   
2020-02-26           -1          0          0          1394.98    181.09   
2020-04-15            1          1    1246.51                0         0   

           cash_onhand position_value total_position accumu_return  
date                                                                
2019-01-07    -1080.97        1075.92          -5.05         -5.05  
2019-05-03       96.44              0          96.44         96.44  
2019-07-08    -1029.43        1116.79          87.36         87.36  
2019-10-04      164.86              0         164.86        164.86  
2019-10-14    -1049.03        1217.77         168.74        168.74  
2020-02-26      345.95              0         345.95        345.95  
2020-04-15     -900.56         1257.3         356.74        356.74  
In [20]:
# Display the entry and exit signals for the top model
print('The trading signal changes from the top model %s:' % (top_model))
print(model_collection[top_model][model_collection[top_model].signal_change != 0])
The trading signal changes from the top model EMA_015_SlowMA_35_FastMA_05:
            open_price  close_price      fast_ma      slow_ma  ma_change  \
date                                                                       
2019-01-04     1042.56      1078.07  1051.575866  1051.266297   0.309569   
2019-05-02     1172.60      1166.51  1204.989272  1210.852394  -5.863121   
2019-07-05     1119.37      1132.66  1115.359963  1113.994334   1.365629   
2019-10-03     1183.34      1189.43  1201.088228  1205.720051  -4.631823   
2019-10-11     1224.03      1215.71  1207.841696  1205.908221   1.933476   
2020-02-25     1431.00      1386.32  1446.815629  1452.577673  -5.762044   
2020-04-14     1239.97      1265.23  1216.218529  1215.737194   0.481335   

            trade_signal  signal_change  entry_exit  
date                                                 
2019-01-04           1.0            1.0         0.0  
2019-05-02           0.0           -1.0         0.0  
2019-07-05           1.0            1.0         0.0  
2019-10-03           0.0           -1.0         0.0  
2019-10-11           1.0            1.0         0.0  
2020-02-25           0.0           -1.0         0.0  
2020-04-14           1.0            1.0         0.0  
In [21]:
graph_data = model_collection[top_model].copy()
title_string = "Exponential Moving Average Crossover Model for " + top_model
fig = plt.figure(figsize=(16,9))
ylabel = stock_symbol + ' price in $'
ax1 = fig.add_subplot(111, ylabel=ylabel, title=title_string)
graph_data['fast_ma'].plot(ax=ax1, color='b', lw=2.)
graph_data['slow_ma'].plot(ax=ax1, color='r', lw=2.)
graph_data['close_price'].plot(ax=ax1, color='g')
ax1.plot(graph_data.loc[graph_data.entry_exit == 1].index, graph_data.close_price[graph_data.entry_exit == 1], '^', markersize=7, color='k',label='buy')
ax1.plot(graph_data.loc[graph_data.entry_exit == -1].index, graph_data.close_price[graph_data.entry_exit == -1], 'v', markersize=7, color='k',label='sell')
plt.legend(loc='upper left')
plt.show()

Task 5. Evaluate Performance

In [22]:
best_model = ''
best_return = 0
for key in portfolio_collection:
    if portfolio_collection[key]['accumu_return'][-1] > best_return:
        best_model = key
        best_return = portfolio_collection[best_model]['accumu_return'][-1]
print('The best model found is:', best_model)
print('The best profit/loss for the investing period is: $%.2f' % (best_return))
if initial_capital != 0:
    print('The best return percentage for initial capital is: %.2f%%' % (best_return / initial_capital * 100))
The best model found is: EMA_015_SlowMA_35_FastMA_05
The best profit/loss for the investing period is: $541.44
In [23]:
worst_model = None
worst_return = 0
for key in portfolio_collection:
    if portfolio_collection[key]['accumu_return'][-1] < worst_return:
        worst_model = key
        worst_return = portfolio_collection[worst_model]['accumu_return'][-1]
print('The worst model found is:', worst_model)
print('The worst profit/loss for the investing period is: $%.2f' % (worst_return))
if initial_capital != 0:
    print('The worst return percentage for the initial capital is: %.2f%%' % (worst_return / initial_capital * 100))
The worst model found is: None
The worst profit/loss for the investing period is: $0.00
In [24]:
# Calculate the stock's performance for a long-only model
model_template = model_template[model_start_date:model_end_date]
print('The performance of the long-only model from day one is: $%.2f' %(model_template.iloc[-1]['close_price'] - model_template.iloc[0]['open_price']))
The performance of the long-only model from day one is: $414.80
In [25]:
print ('Total time for the script:',(datetime.now() - startTimeScript))
Total time for the script: 0:01:42.527020